Skip to content

v0.16.0 no longer distinguishes between "{number}" and number object keys #34

@conorbrandon

Description

@conorbrandon

First off, excellent work on this package!

Unfortunately, the upgrade to v0.16.0 seems to no longer be able to detect when an object has a number property vs. a "stringified" "{number}" property. The following test correctly failed with v0.15.0, but passes with v0.16.0:

type T = {
  1: string;
  "2": string;
};

expectTypeOf<T>().toEqualTypeOf<{
  1: string;
  2: string; // on 0.15.0, this property had to be "2" (a string, not a number)
}>();

Typescript itself doesn't really distinguish between these two cases, so I'd understand why this change was made, but I found the nuance helpful. For instance, this is perfectly legal:

declare const r: Record<number, string>;
r['-1'] = "";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions