Closed
Description
TypeScript Version: 3.5.1
Search Terms:
function, return type, unique symbol
Code
const a = Symbol();
const b = Symbol();
function identity<T> (t : T) : T {
return t;
}
/**
* Mouseover `identity(a)`,
* Tooltip shows,
*
* ```
* function identity<typeof a>(t: typeof a): typeof a
* ```
*/
/**
* Expected : typeof a
*
* Actual : symbol
*/
const actual = identity(a);
/**
* Error
*
* Type 'symbol' is not assignable to type 'unique symbol'.
*/
const expectA : typeof a = actual;
/////////////////////////////////////////////////
function giveTypeOfA () : typeof a {
return a;
}
/**
* Expected : typeof a
*
* Actual : symbol
*/
const actual2 = giveTypeOfA();
/**
* Error
*
* Type 'symbol' is not assignable to type 'unique symbol'.
*/
const expectA2 : typeof a = actual2;
Expected behavior:
actual
and actual2
should be typeof a
Actual behavior:
actual
and actual2
are symbol
Playground Link: Playground
Related Issues:
The very last comment of #24506 asks a question about intended behaviour but it goes unanswered.