Skip to content

Instantly share code, notes, and snippets.

@sweeneyapps
Last active June 18, 2021 18:32
Show Gist options
  • Save sweeneyapps/ecc67271f9342789c3ade46a0921826e to your computer and use it in GitHub Desktop.
Save sweeneyapps/ecc67271f9342789c3ade46a0921826e to your computer and use it in GitHub Desktop.
fixing TypeScript error (before and after)
// Before fixing TypeScript errors
public static registerCommand(context: vscode.ExtensionContext): vscode.Disposable {
const commands = vscode.commands.registerCommand(this.viewType, async () => {
// file chooser
let uri: vscode.Uri | undefined = await vscode.window.showOpenDialog()
this.createOrShow(uri[0]);
});
return commands;
}
// Fixed TypeScript error
public static registerCommand(context: vscode.ExtensionContext): vscode.Disposable {
const commands = vscode.commands.registerCommand(this.viewType, async () => {
// file chooser
let uri: vscode.Uri[] | undefined = await vscode.window.showOpenDialog()
if (uri) this.createOrShow(uri[0]);
});
return commands;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment