Skip to content

Unexpected behavior for WebviewMessageParticipant interface #5

@msujew

Description

@msujew

Currently, using the WebviewMessageParticipant instead leads into a non-obvious pitfall:

export interface WebviewMessageParticipant {
type: 'webview'
/** Identifier of a specific webview instance. */
webviewId?: string
/** Webview panel type or webview view type. */
webviewType?: string
}

As both webviewId and webviewType are optional, I believed them both to be truly optional. However, at least one of them is needed. This fact is not reflected in the type definition. Instead, the type should probably look something like this:

export type WebviewMessageParticipant = WebviewIdMessageParticipant | WebviewTypeMessageParticipant;

export interface WebviewIdMessageParticipant {
    type: 'webview'
    /** Identifier of a specific webview instance. */
    webviewId: string
}

export interface WebviewTypeMessageParticipant {
    type: 'webview'
    /** Webview panel type or webview view type. */
    webviewType: string
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions