Replies: 2 comments 1 reply
-
|
That's indeed quite surprising. I'm cautiously starting to believe that you discovered a Typescript bug. Here is an even simpler reproduction, without fast-check dependency: lib.ts: export declare function property<Ts extends [unknown, ...unknown[]]>(
...args: [
...arbitraries: { [K in keyof Ts]: Ts[K]; },
predicate: (...args: Ts) => void
]
): void;index.js: import { property } from './lib'
property(
2,
[3],
"hello",
(num, numArr, str) => {
// Do something.
},
);Then run ( npx tsc index.js --strictFunctionTypes --module nodenext --checkJs --noEmitIt seems like TypeScript is using two different instantiations of the type variable I can't reproduce it without ...arbitraries: { [K in keyof Ts]: Ts[K]; },to just: ...arbitraries: Ts,(which should be equivalent, right?) then the problem also goes away. So it seems that all these conditions must come together. If this is really a TypeScript bug, it's nothing new. I downgraded all the way to TypeScript 5.2 and can still reproduce this. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the feedback. I added a comment in the issue with a simpler snippet: microsoft/TypeScript#52042 (comment) I agree that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
In my JavaScript project, I check types with TypeScript (and JSDoc). With this use of
fast-check:TypeScript report error:
Argument of type '[(str: string) => void]' is not assignable to parameter of type '[...Arbitrary<unknown>[], predicate: (args_0: unknown, ...args: unknown[]) => boolean | void]'.Do you have a tip for fixing this error?
Files to reproduce the problem:
package.json{ "name": "testcase", "version": "0.0.0", "dependencies": { "fast-check": "3.23.2", "typescript": "5.7.3" } }index.jsnpm installnpx tsc index.js --strict --module nodenext --checkJs --noEmitI've tried forcing the types, but there's always the error.
Beta Was this translation helpful? Give feedback.
All reactions