Bug Report
π Search Terms
FlatArray declaration unknown
π Version & Regression Information
- This changed between versions 4.7.0-dev.20220406 and 4.7.0-dev.20220408 (still present in 4.7.3)
β― Playground Link
Playground link with relevant code (target: es2019)
π» Code
// This function's type is changed on declaration
export const fun = (
subFun: <Collection, Field extends keyof Collection>()
=> FlatArray<Collection[Field], 0>[]) => { };
// This argument should match the type of argument used by fun
const subFunExample = <Collection, Field extends keyof Collection>()
: FlatArray<Collection[Field], 0>[] => [];
// Typescript does not throw any error there
fun(subFunExample);
// This is the type found for fun in the declaration file. It should be equivalent to the type for fun.
const fun_declaration: (subFun: <Collection, Field extends keyof Collection>() => (Collection[Field] extends infer T ? T extends Collection[Field] ? T extends readonly unknown[] ? unknown : T : never : never)[]) => void
= (_) => {};
// Typescript throws an error there.
fun_declaration(subFunExample);
π Actual behavior
When the declaration is created, the type of fun is transformed to (subFun: <Collection, Field extends keyof Collection>() => (Collection[Field] extends infer T ? T extends Collection[Field] ? T extends readonly unknown[] ? unknown : T : never : never)[]) => void;.
This declaration type does not recognize arguments that were matched by the original type.
π Expected behavior
No error. Declaration type should be equivalent to the original type: if typescript does not raise an error with the original type, it should raise an error for the declaration type.
I've tried to find a simpler type exhibiting this behavior, but didn't find any.
Bug Report
π Search Terms
FlatArray declaration unknown
π Version & Regression Information
β― Playground Link
Playground link with relevant code (target: es2019)
π» Code
π Actual behavior
When the declaration is created, the type of fun is transformed to
(subFun: <Collection, Field extends keyof Collection>() => (Collection[Field] extends infer T ? T extends Collection[Field] ? T extends readonly unknown[] ? unknown : T : never : never)[]) => void;.This declaration type does not recognize arguments that were matched by the original type.
π Expected behavior
No error. Declaration type should be equivalent to the original type: if typescript does not raise an error with the original type, it should raise an error for the declaration type.
I've tried to find a simpler type exhibiting this behavior, but didn't find any.