Skip to content

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

Closed

Description

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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