Skip to content

number should be subtype of keyof T[] #13715

Closed
@maiermic

Description

@maiermic

TypeScript Version: 2.1.5

Code

let key: keyof string[]
key = 1 // Type '1' is not assignable to type '"length" | "toString" | "toLocaleString" | "push" | "pop" | "concat" | "join" | "reverse" | "shif...'.
interface Container<T> {
  [index: number]: T
}

let key: keyof Container<string>
key = 1 // Type '1' is not assignable to type 'never'.

Expected behavior:

number should be subtype of keyof string[] and keyof Container<string>

Actual behavior:

number is no subtype of keyof string[] and keyof Container<string>

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions