-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Should create unique symbols when creating properties on module.exports
#37404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@rbuckton @weswigham what do we think should happen here? |
We don't make unique symbols because we see the position as mutable, ie, exports.customSymbol = Symbol("custom1")
// later
exports.customSymbol = Symbol("custom2") is perfectly acceptable. In theory, we could recognize Object.defineProperty(module.exports, "customSymbol", {
writable: false,
value: Symbol("custom")
}); as making the |
But TypeScript complains when you re‑assign a property on
Also, that code looks like a bug to me, so I don’t think it should be the default. Also, if you do: (🔗) const customSymbol = Symbol("custom");
exports.customSymbol = customSymbol; Then you get: export var customSymbol: typeof customSymbol;
declare const customSymbol: unique symbol;
export {}; |
Hm. I didn't realize we issued the |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in this issue running against the nightly TypeScript. Issue body code block by @ExE-Boss
Historical InformationIssue body code block by @ExE-Boss
|
TypeScript Version:
3.9.0-dev.20200315
Search Terms:
Code
Workbench Repro
Expected behavior:
Actual behavior:
Playground Link:
https://www.typescriptlang.org/play?module=1&useJavaScript=true#code/KYDwDg9gTgLgzgOgMYFc4wgWwMoE9MBGEANgAQC8pehJAFAESrpb0CUA3AFBA
Related Issues:
module.exports
#37403The text was updated successfully, but these errors were encountered: