Closed as not planned
Closed as not planned
Description
π Search Terms
function signature wrong pick
As asked, this is a rewrite of the issue #62000
π Version & Regression Information
Tested with the nightly build.
β― Playground Link
π» Code
type OPTIONS = Record<string, unknown>;
type DEFAULT_OPTIONS = {css: string[]};
type TEST_OPTIONS = {css: any[] };
let test: DEFAULT_OPTIONS = {} as TEST_OPTIONS; // TEST_OPTIONS can be cast into DEFAULT_OPTIONS.
/**************************************************************/
{
function LISS( args: DEFAULT_OPTIONS) : true
function LISS( args: OPTIONS,
...extensions: unknown[]): false
function LISS(args: OPTIONS,
...extensions: unknown[]): boolean {
return {} as boolean
}
const a = LISS({} as TEST_OPTIONS); // is false, should be true
const b = LISS({} as DEFAULT_OPTIONS);
}
π Actual behavior
typeof ais
falsewhen it should be
true`: i.e. the second signature overload is chosen.
π Expected behavior
typeof a
should be true
: i.e. the first signature overload should be chosen.
Additional information about the issue
As asked, this is a rewrite of the issue #62000
Using [unknown, ...unknown[]]
fixes the issue in the example (force the second signature to have at least one extension). But the underlying issue might manifest in other cases.