Error on function type that comes from a function declaration that is declared after usage site
Opened this issue · 1 comments
dragomirtitian commented
Steps to reproduce
let arr: any[] = [];
// Move fnDeclaration here and it works
declare let mapFn: typeof fnDeclaration | ((v: any) => number);
// declare let mapFn: ((s: string) => string) | ((v: any) => number); // Also works ok
arr.map(mapFn instanceof Function ? mapFn : i => i); // Error in TS GO
function fnDeclaration(s: string): string {
return s;
}Behavior with typescript@5.8
Type checks without errors.
Behavior with tsgo
If fnDeclaration appears after the usage in typeof fnDeclaration we get an error on the arr.map call.
jakebailey commented
Surely this is yet another type ordering problem, since symbols are sorted by declaration location and swapping the order will mean the function sorts earlier...