-
Notifications
You must be signed in to change notification settings - Fork 34.2k
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
Map
orSet
instead 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.ts
@mjbvz -
vs/base/parts/storage/node/storage.ts
@mjbvz -
vs/code/electron-browser/issue/issueReporterMain.ts
@RMacfarlane -
vs/code/electron-main/window.ts
-
vs/editor/standalone/browser/standaloneLanguages.ts
@mjbvz -
vs/platform/configuration/common/configuration.ts
@sandy081 -
vs/platform/configuration/common/configurationModels.ts
@sandy081 -
vs/platform/configuration/common/configurationRegistry.ts
@sandy081 -
vs/platform/environment/node/environmentService.ts
@sandy081 -
vs/platform/extensionManagement/node/extensionGalleryService.ts
@sandy081 -
vs/platform/instantiation/common/instantiationService.ts
@mjbvz -
vs/platform/windows/electron-main/windowsService.ts
@bpasero -
vs/workbench/api/browser/mainThreadTreeViews.ts
@sandy081 -
vs/workbench/api/common/extHostTreeViews.ts
@sandy081 -
vs/workbench/browser/editor.ts
@bpasero -
vs/workbench/browser/parts/editor/editorStatus.ts
@mjbvz -
vs/workbench/browser/parts/views/viewsViewlet.ts
@sandy081 -
vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
-
vs/workbench/contrib/debug/browser/rawDebugSession.ts
@isidorn -
vs/workbench/contrib/debug/test/node/debugger.test.ts
@isidorn -
vs/workbench/contrib/experiments/electron-browser/experimentService.ts
-
vs/workbench/contrib/extensions/common/extensionQuery.ts
@mjbvz -
vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts
@sandy081 -
vs/workbench/contrib/localizations/browser/localizations.contribution.ts
@sandy081 -
vs/workbench/contrib/preferences/browser/keybindingsEditor.ts
@sandy081 -
vs/workbench/contrib/preferences/browser/settingsEditor2.ts
@roblourens -
vs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourens -
vs/workbench/contrib/preferences/electron-browser/preferencesSearch.ts
@roblourens -
vs/workbench/contrib/quickopen/browser/viewPickerHandler.ts
-
vs/workbench/contrib/tasks/common/taskConfiguration.ts
@alexr00 -
vs/workbench/electron-browser/window.ts
@bpasero -
vs/workbench/services/extensions/common/abstractExtensionService.ts
@alexandrudima -
vs/workbench/services/extensions/common/extensionsRegistry.ts
@alexandrudima -
vs/workbench/services/keybinding/common/keybindingEditing.ts
@sandy081 -
vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts
@sandy081