Skip to content

Exclude not work on [key: string]:any #31153

Description

@vipcxj

TypeScript Version: 3.4.4

Search Terms:

Code

interface TestType {
   a: number;
   b: string;
   [key:string]: any;
}
type NTestType1 = {
   [P in keyof TestType]: any;
}
const test:NTestType1 = {} // error missing a and b. this is correct.
type NTestType2 = {
   [P in Exclude<keyof TestType, 'a'>]: any;
}
const test::NTestType2 = {} // no error, we expect show missing b error here.

Expected behavior:
show missing b error

Actual behavior:
no error

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions