Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression in 4.5 - recursive conditional type with generic input fails to narrow #46171

Closed
DetachHead opened this issue Oct 2, 2021 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@DetachHead
Copy link
Contributor

Bug Report

πŸ”Ž Search Terms

4.5 recursive conditional type narrow generic

πŸ•— Version & Regression Information

4.5.0-dev.20211001

  • This changed between versions 4.4.3 and 4.5.0-beta

⏯ Playground Link

πŸ’» Code

type ArrayLength<
    Length extends number,
    CurrentArray extends never[]
> = CurrentArray['length'] extends Length
    ? CurrentArray
    : ArrayLength<Length, [never, ...CurrentArray]>

type WrapArray<T extends unknown[]> = T

//error: Type 'ArrayLength<T, []>' does not satisfy the constraint 'unknown[]'
export type Foo<T extends number> = WrapArray<ArrayLength<T, []>>

πŸ™ Actual behavior

error: Type 'ArrayLength<T, []>' does not satisfy the constraint 'unknown[]'

πŸ™‚ Expected behavior

no error

@ruohola
Copy link

ruohola commented Oct 3, 2021

Is this the same underlying issue as #46183?

@DetachHead
Copy link
Contributor Author

DetachHead commented Oct 3, 2021

yep i'm pretty sure

@sandersn sandersn added the Duplicate An existing issue was already created label Oct 7, 2021
@sandersn sandersn closed this as completed Oct 7, 2021
@DetachHead
Copy link
Contributor Author

why was my issue marked as a duplicate of the newer one lol

@andrewbranch
Copy link
Member

The newer one was already labeled/assigned and had useful discussion on it πŸ˜„

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants