Hi! As the title says, I'm wondering why TypeScript doesn't catch this infinite recursion unless I actually use the type.
// No errors in this code!
type s3<a extends readonly string[]> = a extends [
infer b extends string,
...infer c extends readonly string[]
]
? s3<c>
: s3<a>;
// ^^^^^ This is definitely causing infinite recursion
type s3<a extends readonly string[]> = a extends [
infer b extends string,
...infer c extends readonly string[]
]
? s3<c>
: s3<a>;
type L = s3<["hi"]>;
// ^^^^^^^^^^ Error: Type instantiation is excessively deep and possibly infinite.
I'm just wondering what the heuristics for this are. Thanks in advance!
Hi! As the title says, I'm wondering why TypeScript doesn't catch this infinite recursion unless I actually use the type.
I'm just wondering what the heuristics for this are. Thanks in advance!