-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
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.
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug