-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove suppressImplicitAnyIndexErrors #76442
Comments
TypeScript seems to not understand iteration with interface MyObject {
a: string;
b: string;
}
const myObject : MyObject = { a: "val1", b: "val2" };
for (const key in myObject) {
console.log(myObject[key]) // typescipt doesnt like this, why?
} |
I started to use the following workaround to be able to use interface MyObject {
a: string;
b: string;
}
const myObject : MyObject = { a: "val1", b: "val2" };
for (const objectKey in myObject) {
const key = <keyof typeof myObject> objectKey;
console.log(myObject[key])
} |
@aeschli See this comment for more info about the issue: microsoft/TypeScript#31087 (comment) |
Only around 85 errors left. I've updated the list and assigned some initial owners |
@mjbvz I compiled VS Code today using |
@dbaeumer run |
Thanks. |
@bpasero can I also 'unmix' ? |
@dbaeumer |
@aeschli Thanks |
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:
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
@mjbvzvs/base/parts/storage/node/storage.ts
@mjbvzvs/code/electron-browser/issue/issueReporterMain.ts
@RMacfarlanevs/code/electron-main/window.ts
vs/editor/standalone/browser/standaloneLanguages.ts
@mjbvzvs/platform/configuration/common/configuration.ts
@sandy081vs/platform/configuration/common/configurationModels.ts
@sandy081vs/platform/configuration/common/configurationRegistry.ts
@sandy081vs/platform/environment/node/environmentService.ts
@sandy081vs/platform/extensionManagement/node/extensionGalleryService.ts
@sandy081vs/platform/instantiation/common/instantiationService.ts
@mjbvzvs/platform/windows/electron-main/windowsService.ts
@bpaserovs/workbench/api/browser/mainThreadTreeViews.ts
@sandy081vs/workbench/api/common/extHostTreeViews.ts
@sandy081vs/workbench/browser/editor.ts
@bpaserovs/workbench/browser/parts/editor/editorStatus.ts
@mjbvzvs/workbench/browser/parts/views/viewsViewlet.ts
@sandy081vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
vs/workbench/contrib/debug/browser/rawDebugSession.ts
@isidornvs/workbench/contrib/debug/test/node/debugger.test.ts
@isidornvs/workbench/contrib/experiments/electron-browser/experimentService.ts
vs/workbench/contrib/extensions/common/extensionQuery.ts
@mjbvzvs/workbench/contrib/extensions/electron-browser/extensionEditor.ts
@sandy081vs/workbench/contrib/localizations/browser/localizations.contribution.ts
@sandy081vs/workbench/contrib/preferences/browser/keybindingsEditor.ts
@sandy081vs/workbench/contrib/preferences/browser/settingsEditor2.ts
@roblourensvs/workbench/contrib/preferences/browser/settingsTree.ts
@roblourensvs/workbench/contrib/preferences/electron-browser/preferencesSearch.ts
@roblourensvs/workbench/contrib/quickopen/browser/viewPickerHandler.ts
vs/workbench/contrib/tasks/common/taskConfiguration.ts
@alexr00vs/workbench/electron-browser/window.ts
@bpaserovs/workbench/services/extensions/common/abstractExtensionService.ts
@alexandrudimavs/workbench/services/extensions/common/extensionsRegistry.ts
@alexandrudimavs/workbench/services/keybinding/common/keybindingEditing.ts
@sandy081vs/workbench/services/workspace/electron-browser/workspaceEditingService.ts
@sandy081The text was updated successfully, but these errors were encountered: