-
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
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
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