Closed
Description
Bug Report
Found while working on nodejs/node#38198
π Search Terms
unique symbol object
β― Playground Link
Playground link with relevant code
π» Code
declare const kSomeConstant: unique symbol;
declare function test(value: typeof kSomeConstant): void;
declare function getExports(): {
kSomeConstant: typeof kSomeConstant;
test: typeof test;
}
/*
const exp: {
kSomeConstant: typeof kSomeConstant;
test: typeof test;
}
*/
const exp = getExports()
// (property) kSomeConstant: typeof kSomeConstant
exp.test(exp.kSomeConstant)
// const constant: symbol
const constant = exp.kSomeConstant;
exp.test(constant);
π Actual behavior
exp.test(constant)
is an error, because constant
's type is inferred to symbol
instead of typeof kSomeConstant
.
π Expected behavior
The extracted variable should have the same type