apache / apache/daffodil-vscode

Implement MessageCommand Interfaces per Enumeration

Open
#669 1 comment 0 reactions 2 assignees Claimed by @nlewis05 View on GitHub
code quality data editor
Dominant language
TypeScript
Stars
18
Forks
33
Avg merge
3d 6h
Merged PRs (30d)
7

Description

### 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**
```ts
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.
```ts
window.addEventListener('message', (msg) => {
switch (msg.data.command) {
case MessageCommand.test:
const data = msg.data.data as TestCommand
...
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.