-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.9.1, 3.0.0-dev.20180608
Search Terms:
keyof generics extend exclude
Code
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
interface RequiredFields {
requiredField: string;
requiredField2: string;
}
// works
interface MyInterface extends RequiredFields { }
type ExcludeTest = Exclude<MyInterface, "">;
type Fields = Omit<MyInterface, "">;
const test = (props: Fields) => {
const { requiredField } = props;
}
// doesnt work
const generator = <T extends RequiredFields>() => {
type ExcludeTest = Exclude<T, "">; // wrong
type PickTest = Pick<T, "requiredField">;
type Fields = Omit<T, "">;
const tmp = (props: Fields) => {
const { } = props; // requiredField doesnt exist
}
return tmp;
}
Expected behavior:
Props in generator should have RequiredFields fields.
Actual behavior:
Props are empty.
Playground Link: Link
Related Issues:
#21941 #21862.
The issues are closed but the bug is still here
poseidonCore, tanglebones, wmathes and flohil
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue