Skip to content

keyof "a" behaves differently when using a type parameter #23345

Closed
@ghost

Description

TypeScript Version: 2.9.0-dev.20180411

Code

type A = { [P in keyof "a"]?: boolean }; // { padStart?: boolean | undefined, ... }
type Indirect<T> = { [P in keyof T]?: boolean };
type B = Indirect<"a">; // "a"

declare const a: A;
const b: B = a; // Error

Expected behavior:

No error. B is the same as A.

Actual behavior:

Error: B is the string literal type "a".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions