-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
While studying your source code to finish with rust-lang/rust-analyzer#3053 I've stumbled with these lines of code.
vscode-cpptools/Extension/src/githubAPI.ts
Lines 38 to 43 in 3fa056f
| const downloadUrl: string = build.assets.find(asset => { | |
| return asset.name === vsixName; | |
| }).browser_download_url; | |
| if (!downloadUrl) { | |
| throw new Error(`Failed to find VSIX: ${vsixName} in build: ${build.name}`); | |
| } |
From my perspective, it is apparent that if the release doesn't contain the needed
.vsix file (which is a developer mistake that should never happen) you will get TypeError: Cannot read property 'browser_download_url' of undefined, instead of undefined written to downloadUrl. Thus, that true branch of the if statement is unreachable now.
In order to avoid such mistakes I strongly recommend you to set "strictNullChecks": true in tsconfig.json. The migration process for it is pretty straightforward, you just slap non-null assertions (i.e. postfix ! operator) everywhere the compiler sees a bug and later fix these places.
