Skip to content

Commit

Permalink
fix: add type safety checks using 'data satisfies never' in various c…
Browse files Browse the repository at this point in the history
…omponents
  • Loading branch information
tamuratak committed Jan 20, 2025
1 parent 275d493 commit 25d659e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export class Viewer {
break
}
default: {
data satisfies never
this.extension.logger.error(`Unknown websocket message: ${msg}`)
break
}
Expand Down
7 changes: 4 additions & 3 deletions src/providers/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class Completer implements vscode.CompletionItemProvider {
}

private async completion(
type: CompletionType,
ctype: CompletionType,
line: string,
args: {
document: vscode.TextDocument,
Expand All @@ -221,7 +221,7 @@ export class Completer implements vscode.CompletionItemProvider {
) {
let reg: RegExp | undefined
let provider: IProvider | undefined
switch (type) {
switch (ctype) {
case 'citation':
reg = /(?:\\[a-zA-Z]*[Cc]ite[a-zA-Z]*\*?(?:\([^[)]*\)){0,2}(?:<[^<>]*>|\[[^[\]]*\]|{[^{}]*})*{([^}]*)$)|(?:\\bibentry{([^}]*)$)/
provider = this.citation
Expand Down Expand Up @@ -267,8 +267,9 @@ export class Completer implements vscode.CompletionItemProvider {
provider = this.glossary
break
default:
ctype satisfies never
// This shouldn't be possible, so mark as error case in log.
this.extension.logger.error(`Error - trying to complete unknown type: ${inspectCompact(type)}`)
this.extension.logger.error(`Error - trying to complete unknown type: ${inspectCompact(ctype)}`)
return []
}
const result = line.match(reg)
Expand Down
1 change: 1 addition & 0 deletions viewer/components/extensionconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class ExtensionConnection {
break
}
default: {
data satisfies never
break
}
}
Expand Down
1 change: 1 addition & 0 deletions viewer/components/panelmanagerconnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class PanelManagerConnection {
break
}
default: {
data satisfies never
break
}
}
Expand Down

0 comments on commit 25d659e

Please sign in to comment.