-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
needs-investigationFurther information is requestedFurther information is requestedsubtypingRelated to comparing two typesRelated to comparing two typestsc-behaviourTrying to match TSC behaviourTrying to match TSC behaviour
Description
The following code should type-check fine
type Head<T> = T extends [infer H, ...Array<any>] ? H : never;
type Tail<T> = T extends [any, ...infer Tail] ? Tail : [];
1 satisfies Head<[1, 2, 3, 4, 5]>;
[2, 3, 4, 5] satisfies Tail<[1, 2, 3, 4, 5]>;
There is some current problems with representing spread arrays patterns. It isn't great as it reuses the same object helper as regular expression space array literals (and so doesn't create an anonymous object literal type). Maybe this could be handled regularly, maybe there needs to be a special fn extract_as_slice
helper method?
Metadata
Metadata
Assignees
Labels
needs-investigationFurther information is requestedFurther information is requestedsubtypingRelated to comparing two typesRelated to comparing two typestsc-behaviourTrying to match TSC behaviourTrying to match TSC behaviour