Open
Description
TypeScript Version: 2.7.0-dev.20180418
Search Terms: Intellisense overload, tooltip overload
Code
function test<A>(a: A): true;
function test<A, B>(a: A, b: B): false;
function test<T>(...values: T[]): boolean {
return values.length === 1;
}
declare function assertTrue(truth: true): void;
const noComma = test( // test<string>(a: string): true
'foo'
)
assertTrue(noComma);
const withComma = test( // test<string, {}>(a: string, b: {}): false, but withComma: true
'foo',
);
assertTrue(withComma);
assertTrue(test( // test<string, {}>(a: string, b: {}): false, but no error
'foo',
));
Expected behavior:
The inferred version of test
(as shown in hover-over tooltip) for noComma
, withComma
, and directly passed to assertTrue
is the test<A>(a: A): true
version.
Actual behavior:
The inferred version of test
for the withComma
and directly-passed versions is the test<A, B>(a: A, b: B): false
, specifically test<string, {}>(a: string, b: {}): false
.
Despite this, withComma
has type true
, and no error is reported for the call to assertTrue
with it or when directly passed.
Playground Link: here
Related Issues: #7279