Skip to content
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

Fix "implicit any" Typescript errors to prepare for Typescript 5.5 #1817

Merged
merged 3 commits into from
May 27, 2024

Commits on May 21, 2024

  1. Teach Typescript about the types of field keys

    Typescript 5.5 disallows the "suppressImplicitAnyIndexErrors", so we
    need to go through the code, find any places where an index has an
    implicit "any" type, and annotate those places with the correct type so
    that Typescript won't complain about them.
    
    This commit makes a start on this task.
    rmunn committed May 21, 2024
    Configuration menu
    Copy the full SHA
    d8d76b9 View commit details
    Browse the repository at this point in the history

Commits on May 22, 2024

  1. Fix more Typescript "implicit any" index errors

    In a couple places, we do `if foo.hasOwnProperty(bar)` followed by
    getting the value of `foo[bar]`, but Typescript warns that "string"
    isn't a valid property name of `foo`. It should recognize that the
    hasOwnProperty check means it's safe to access `foo[bar]`, but it
    doesn't. We can either change those to be `if bar in foo` which
    Typescript *does* recognize as a type guard, or else we can just leave
    the code as-is and add @ts-expect-error comments. Since `bar in foo` is
    not quite identical to `foo.hasOwnProperty(bar)` (`bar in foo` climbs
    inheritance hierarchies whereas `.hasOwnProperty` doesn't), I chose to
    leave the code as-is rather than subtly change its behavior.
    rmunn committed May 22, 2024
    Configuration menu
    Copy the full SHA
    32aa397 View commit details
    Browse the repository at this point in the history
  2. Remove suppressImplicitAnyIndexErrors from tsconfig

    Now that we've fixed the implicit "any" index errors, we can remove this
    line from tsconfig. (It will be going away in Typescript 5.5 anyway).
    rmunn committed May 22, 2024
    Configuration menu
    Copy the full SHA
    c92e2e6 View commit details
    Browse the repository at this point in the history