Repository navigation
Description
Although VS Code is now strict null checked, we currently set "suppressImplicitAnyIndexErrors": true. This setting allows using bracket accessors on values, even if the value's type does not specifically have an index access signature.
This is bad because it can easily end up hiding errors that TypeScript could have caught:
const map = new Map()
map.set('property', true);
...
if (map['property']) { // This is not an TS error but it does not do what you want!
doImportantStuff();
} Fix
The good news is that there are only around 240 errors total and these errors are typically not too difficult to fix. Here's the process:
-
In
./src/tsconfig.base.json, set"suppressImplicitAnyIndexErrors": false -
Restart the compile (if using
watch) -
Open the file you wish to fix errors in and fix the errors:
Potential fixes include:
-
Use a
MaporSetinstead of an object literal. -
Add an index signature to the type
-
Cast to a type with an index signature (or any)
-
Here's the complete list of files with errors. I've assigned a few potential owners but feel free to claim others:
-
vs/base/common/console.tsMatt Bierner (@mjbvz) -
vs/base/parts/storage/node/storage.tsMatt Bierner (@mjbvz) -
vs/code/electron-browser/issue/issueReporterMain.tsRachel Macfarlane (@RMacfarlane) -
vs/code/electron-main/window.ts -
vs/editor/standalone/browser/standaloneLanguages.tsMatt Bierner (@mjbvz) -
vs/platform/configuration/common/configuration.tsSandeep Somavarapu (@sandy081) -
vs/platform/configuration/common/configurationModels.tsSandeep Somavarapu (@sandy081) -
vs/platform/configuration/common/configurationRegistry.tsSandeep Somavarapu (@sandy081) -
vs/platform/environment/node/environmentService.tsSandeep Somavarapu (@sandy081) -
vs/platform/extensionManagement/node/extensionGalleryService.tsSandeep Somavarapu (@sandy081) -
vs/platform/instantiation/common/instantiationService.tsMatt Bierner (@mjbvz) -
vs/platform/windows/electron-main/windowsService.tsBenjamin Pasero (@bpasero) -
vs/workbench/api/browser/mainThreadTreeViews.tsSandeep Somavarapu (@sandy081) -
vs/workbench/api/common/extHostTreeViews.tsSandeep Somavarapu (@sandy081) -
vs/workbench/browser/editor.tsBenjamin Pasero (@bpasero) -
vs/workbench/browser/parts/editor/editorStatus.tsMatt Bierner (@mjbvz) -
vs/workbench/browser/parts/views/viewsViewlet.tsSandeep Somavarapu (@sandy081) -
vs/workbench/contrib/comments/browser/commentsEditorContribution.ts -
vs/workbench/contrib/debug/browser/rawDebugSession.tsIsidor Nikolic (@isidorn) -
vs/workbench/contrib/debug/test/node/debugger.test.tsIsidor Nikolic (@isidorn) -
vs/workbench/contrib/experiments/electron-browser/experimentService.ts -
vs/workbench/contrib/extensions/common/extensionQuery.tsMatt Bierner (@mjbvz) -
vs/workbench/contrib/extensions/electron-browser/extensionEditor.tsSandeep Somavarapu (@sandy081) -
vs/workbench/contrib/localizations/browser/localizations.contribution.tsSandeep Somavarapu (@sandy081) -
vs/workbench/contrib/preferences/browser/keybindingsEditor.tsSandeep Somavarapu (@sandy081) -
vs/workbench/contrib/preferences/browser/settingsEditor2.tsroblourens -
vs/workbench/contrib/preferences/browser/settingsTree.tsroblourens -
vs/workbench/contrib/preferences/electron-browser/preferencesSearch.tsroblourens -
vs/workbench/contrib/quickopen/browser/viewPickerHandler.ts -
vs/workbench/contrib/tasks/common/taskConfiguration.tsAlex Ross (@alexr00) -
vs/workbench/electron-browser/window.tsBenjamin Pasero (@bpasero) -
vs/workbench/services/extensions/common/abstractExtensionService.tsalexandrudima -
vs/workbench/services/extensions/common/extensionsRegistry.tsalexandrudima -
vs/workbench/services/keybinding/common/keybindingEditing.tsSandeep Somavarapu (@sandy081) -
vs/workbench/services/workspace/electron-browser/workspaceEditingService.tsSandeep Somavarapu (@sandy081)
Activity
refs #76442
Fix some implictIndex errors
Remove suppressImplicitAnyIndexErrors from tasks
some of #76442
Remove suppressImplicitAnyIndexErrors (#76442)
Use Map instead of object map
Supress implicit index error with any
Add explicit index signature
Add scripts property to manifest so that index access is valid
Fix a few more implicit index errors
Fixing/supressing more implictIndex errors
Fixing/supressing more implict index errors
16 remaining items
#76442 fix implicit any
Implicity any in taskConfiguration.ts
implicit any (#76442)
Fix or supress more implict index access errors
Fix implicit index errors and switch to use for-of loops
Fixing / supressing more implict index errors
dbaeumer commentedon Jul 11, 2019
Matt Bierner (@mjbvz) I compiled VS Code today using
yarn run gulp compileand I receive a ton of compile errors. Looking at the list in the description not everyone seems to have the work done. Any reason why the compiler flag got already removed.bpasero commentedon Jul 11, 2019
Dirk Bäumer (@dbaeumer) run
gulp mixin-serverand try again.dbaeumer commentedon Jul 11, 2019
Thanks.
dbaeumer commentedon Jul 11, 2019
Benjamin Pasero (@bpasero) can I also 'unmix' ?
aeschli commentedon Jul 11, 2019
Dirk Bäumer (@dbaeumer)
git clean -xdf. Of course don't do this while you have uncommited changes.dbaeumer commentedon Jul 11, 2019
Martin Aeschlimann (@aeschli) Thanks