🔎 Search Terms
"excessive stack depth", "ts2321"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.3#code/C4TwDgpgBAShCGATA9gOwDYgCoFczogB4sAaKAOSggA9gJVEBnKVHAWwCMIAnMmK2vSZQAgt27wQxAHxQAvFADaAXVlyAUAEgYigOQFUAc2AALXcoF0Gzcuqj2oAfijcEKDCCUA6HzGV2HAC5YNzRMXHwiUgoyRWifLz9pAG51dVBIUXFJAFkAS1RyYjJKGithVk4eNRZ2Lm5LIRsA5zEJKSxpAODSwWsoAAYA+1bsjq6HKGDFBLgkMOw8AmKKaTIEtskZZVT1RAgAY3R4VygAMxxUA+A8tCgTeEYRYAAZBEZgFd7y5kr66QAFAFEPBgPBgnN3JhNuMSAE2AU8mx2D04QBKYIgsFQPLMGH5QpfFJAA
💻 Code
typeReadonlyTuple<T,Nextendsnumber,RextendsArray<T>=[]>=R['length']extendsN
? readonly[...R]
: ReadonlyTuple<T,N,[T, ...R]>;typeArrayMinN<T,Nextendsnumber>=numberextendsN
? Array<T>
: Nextends0
? Array<T>
: [...ReadonlyTuple<T,N>, ...Array<T>];declarefunctionhasAtLeast<T,Nextendsnumber>(data: ReadonlyArray<T>,minimum: N,): data is ArrayMinN<T,N>;
🙁 Actual behavior
The function hasAtLeast does not typecheck, with an error on the return type data is ArrayMinN<T, N>;: "Excessive stack depth comparing types 'ArrayMinN<T, N>' and 'readonly T[]'.(2321)"
🙂 Expected behavior
No type error.
Additional information about the issue
This was reported in remeda/remeda#572.
It's not clear to me whether this is working as intended, though it is a regression. It's not hard to rewrite the type to make it work, but wondering if it's a Deeper Problem™.
🔎 Search Terms
"excessive stack depth", "ts2321"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.3#code/C4TwDgpgBAShCGATA9gOwDYgCoFczogB4sAaKAOSggA9gJVEBnKVHAWwCMIAnMmK2vSZQAgt27wQxAHxQAvFADaAXVlyAUAEgYigOQFUAc2AALXcoF0Gzcuqj2oAfijcEKDCCUA6HzGV2HAC5YNzRMXHwiUgoyRWifLz9pAG51dVBIUXFJAFkAS1RyYjJKGithVk4eNRZ2Lm5LIRsA5zEJKSxpAODSwWsoAAYA+1bsjq6HKGDFBLgkMOw8AmKKaTIEtskZZVT1RAgAY3R4VygAMxxUA+A8tCgTeEYRYAAZBEZgFd7y5kr66QAFAFEPBgPBgnN3JhNuMSAE2AU8mx2D04QBKYIgsFQPLMGH5QpfFJAA
💻 Code
🙁 Actual behavior
The function
hasAtLeastdoes not typecheck, with an error on the return typedata is ArrayMinN<T, N>;: "Excessive stack depth comparing types 'ArrayMinN<T, N>' and 'readonly T[]'.(2321)"🙂 Expected behavior
No type error.
Additional information about the issue
This was reported in remeda/remeda#572.
It's not clear to me whether this is working as intended, though it is a regression. It's not hard to rewrite the type to make it work, but wondering if it's a Deeper Problem™.