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

Inferring within mapped tuple's type parameter raises error unexpectedly #48026

Closed
Semesse opened this issue Feb 24, 2022 · 2 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@Semesse
Copy link

Semesse commented Feb 24, 2022

Bug Report

πŸ”Ž Search Terms

  • mapped tuple

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried from 3.5.1 to the latest nightly (4.7.0-dev.20220215)

⏯ Playground Link

Playground

πŸ’» Code

type SomeFunction = (...args: any) => any
type SomeMappedTuple<T extends readonly unknown[] | []> = { [P in keyof T]: Promise<T[P]> }
// ok if we put `infer` outside of the type parameter of SomeMappedTuple
type A<T extends SomeFunction> = T extends (...args: infer P) => any ? (...args: SomeMappedTuple<P>) => void : any
// error: A rest parameter must be of an array type
type B<T extends SomeFunction> = (...args: SomeMappedTuple<T extends (...args: infer P) => any ? P : any>) => void

// but in both cases there's no error inferring the correct type
type a = A<(a: string, b: number) => void>
type b = A<(a: string, b: number) => void>

πŸ™ Actual behavior

An error is raised for type B: A rest parameter must be of an array type, where the type parameter passed into SomeMappedTuple should be unknown[] or any

πŸ™‚ Expected behavior

type B should not raise any error

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Feb 25, 2022
@RyanCavanaugh
Copy link
Member

See #29919

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

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

3 participants