-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options
Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
Why are the results different in the following cases?
type T = { [K in keyof never]: string };
// ^? type T = {}type Keys = keyof never;
// ^? type T = string | number | symbol
type T = { [K in Keys]: string };
// ^? type T = {
// [x: string]: string;
// [x: number]: string;
// [x: symbol]: string;
// }The second example makes sense to me — keyof never evaluates to string | number | symbol, so we get back index signatures as expected. But it's unclear why the first example produces an empty object instead.
Also, when generics are involved the result becomes never. This should also have been an index signature.
type Test<T> = { [K in keyof T]: string };
type T = Test<never>;
// ^? type T = neverMetadata
Metadata
Assignees
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options