Issue
The MessageCommand enumeration represents the potential message types that are communicated back and forth, via websockets, between the dataEditorClient object and its WebViewPanel.
Svelte components append an event listener to the DOM that listen for different enumerations of MessageCommand and act accordingly. Though, developers are unable to confidently index into the msg.data.data object because that portion of the message is always initialized inline.
Example
vscode.postMessage({
command: MessageCommand.testCommand ,
data: {
a: 'a',
b: 'b',
}
})
Because of this, there is no index / intellisense relating to the data object.
Solution
Create and implement an interface, type, or data structure that would allow a developer to type cast the data portion of the VSCode message and accurately determine the structure of each MessageCommand enumeration.
Example
Receiving a message.
window.addEventListener('message', (msg) => {
switch (msg.data.command) {
case MessageCommand.test:
const data = msg.data.data as TestCommand
...
Issue
The
MessageCommandenumeration represents the potential message types that are communicated back and forth, via websockets, between the dataEditorClient object and its WebViewPanel.Svelte components append an event listener to the DOM that listen for different enumerations of
MessageCommandand act accordingly. Though, developers are unable to confidently index into themsg.data.dataobject because that portion of the message is always initialized inline.Example
Because of this, there is no index / intellisense relating to the data object.
Solution
Create and implement an interface, type, or data structure that would allow a developer to type cast the data portion of the VSCode message and accurately determine the structure of each
MessageCommandenumeration.Example
Receiving a message.