Microsoft/TypeScript
GitHub ã§èŠãIncorrect emitted declaration for unique symbol re-assignment
Open
#62,305 opened on 2025幎8æ19æ¥
BugDomain: Declaration EmitHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
"TS1332", "unique symbol readonly", "function readonly property"
ð Version & Regression Information
N/A.
⯠Playground Link
ð» Code
const mySymbol = Symbol('Symbols.mySymbol');
const Symbols = {
mySymbol
} as const;
function myFunction() {}
myFunction.mySymbol = Symbols.mySymbol;
/*
SEE `.D.TS` TAB. THE ABOVE CODE PRODUCES:
declare namespace myFunction {
var mySymbol: unique symbol;
}
WHICH IS AN ERROR (TS1332: A variable whose type is a 'unique symbol' type must be const)
*/
export {myFunction}
ð Actual behavior
Compiler produces:
declare namespace myFunction {
var mySymbol: unique symbol;
}
ð Expected behavior
Should be:
declare namespace myFunction {
const mySymbol: unique symbol;
}
Additional information about the issue
Behaves differently when not in a module (remove export {myFunction} in the Playground)