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

TypeScript 4.2.* can't type check utils/internal/compose.d.ts PickLastInTuple<T> #615

Closed
rabelloo opened this issue Feb 25, 2021 · 2 comments · Fixed by #627
Closed

TypeScript 4.2.* can't type check utils/internal/compose.d.ts PickLastInTuple<T> #615

rabelloo opened this issue Feb 25, 2021 · 2 comments · Fixed by #627
Assignees
Labels
bug Something isn't working scope:typescript

Comments

@rabelloo
Copy link

rabelloo commented Feb 25, 2021

Describe the bug

After updating from TypeScript 4.1.5 to 4.2.2 msw can no longer be type-checked with tsc --noEmit.

node_modules/msw/lib/types/utils/internal/compose.d.ts(6,65):
  error TS2344: Type 'PickLastInTuple<T>' does not satisfy the constraint '(...args: any) => any'.
    Type 'unknown' is not assignable to type '(...args: any) => any'.

I don't think I even use that type, but because it is included in msw/index.d.ts TypeScript wants it to pass :/

Environment

  • msw: 0.26.2
  • nodejs: 14.13.0
  • npm: 7.5.4
  • typescript: 4.2.2

To Reproduce

Steps to reproduce the behavior:

  1. Install msw@0.26.2 and typescript@4.2.2
  2. Create a file that imports anything from msw
  3. Try to type-check said file with tsc --noEmit

Expected behavior

TypeScript can type-check msw, in specific PickLastInTuple<T>

@kettanaito
Copy link
Member

@rabelloo, thank you for reporting this! The issue is fixed and will be released in the next patch version.

@ngame2011
Copy link

A temporary solution that worked for me:

type ParametersOrNot<T> = T extends (...args: any[]) => any ? Parameters<T> : never;

declare type FirstFnParameterType<T extends any[]> = ParametersOrNot<PickLastInTuple<T>>[any];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope:typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants