Skip to content

Remove suppressImplicitAnyIndexErrors #76442

Closed

Description

@mjbvz

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:

  1. In ./src/tsconfig.base.json, set "suppressImplicitAnyIndexErrors": false

  2. Restart the compile (if using watch)

  3. Open the file you wish to fix errors in and fix the errors:

    Potential fixes include:

    • Use a Map or Set 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:

Activity

  1. added
    debt
    on Jul 2, 2019
  2. added a commit that references this issue on Jul 2, 2019
  3. added a commit that references this issue on Jul 2, 2019
  4. 16 remaining items

  5. added a commit that references this issue on Jul 9, 2019
  6. dbaeumer commented on Jul 11, 2019

    @dbaeumer
    Member

    Matt Bierner (@mjbvz) I compiled VS Code today using yarn run gulp compile and 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.

  7. bpasero commented on Jul 11, 2019

    @bpasero
    Contributor

    Dirk Bäumer (@dbaeumer) run gulp mixin-server and try again.

  8. dbaeumer commented on Jul 11, 2019

    @dbaeumer
    Member

    Thanks.

  9. dbaeumer commented on Jul 11, 2019

    @dbaeumer
    Member

    Benjamin Pasero (@bpasero) can I also 'unmix' ?

  10. aeschli commented on Jul 11, 2019

    @aeschli
    Contributor

    Dirk Bäumer (@dbaeumer) git clean -xdf. Of course don't do this while you have uncommited changes.

  11. dbaeumer commented on Jul 11, 2019

    @dbaeumer
    Member
  12. locked and limited conversation to collaborators on Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debt

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions