You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should preserve unique symbols when re‑assigning module.exports #37403
// @target: ES2015// @module: CommonJS// @allowJs// @checkJs// @noEmit// @filename: index.jsconstcustomSymbol=Symbol("custom");// ^?// This is a common pattern in Node’s built-in modules:module.exports={
customSymbol,// ^?};
Also, the following requires a // @ts‑ignore comment, but otherwise works:
// some-module.jsconstcustomSymbol=Symbol("custom");// This is a common pattern in Node’s built-in modules:module.exports={/** @type {typeof customSymbol} */// @ts-ignore
customSymbol,// ~~~~~~~~~~~~ TS2322: Type 'symbol' is not assignable to type 'unique symbol'.};
Also, the following requires a // @ts‑ignore comment, but otherwise works:
// some-module.jsconstcustomSymbol=Symbol("custom");// This is a common pattern in Node’s built-in modules:module.exports={/** @type {typeof customSymbol} */// @ts-ignore
customSymbol,// ~~~~~~~~~~~~ TS2322: Type 'symbol' is not assignable to type 'unique symbol'.};
👋 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 2 repros in this issue running against the nightly TypeScript.
// @target: ES2015// @module: CommonJS// @allowJs// @checkJs// @noEmit// @filename: index.js// This is also a common pattern in Node’s built-in modules:module.exports={customSymbol: Symbol("custom"),// ^?};
Activity
ExE-Boss commentedon May 3, 2020
Also, the following requires a
// @ts‑ignorecomment, but otherwise works:1 remaining item
typescript-bot commentedon Mar 10, 2021
👋 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 2 repros in this issue running against the nightly TypeScript.
Issue body code block by ExE Boss (@ExE-Boss)
Comment by ExE Boss (@ExE-Boss)const customSymbol: typeof customSymbol(property) customSymbol: symbol(property) customSymbol: symbolHistorical Information
Issue body code block by ExE Boss (@ExE-Boss)
const customSymbol: typeof customSymbol(alias) const customSymbol: typeof customSymbol import customSymbolconst customSymbol: typeof customSymbol(property) customSymbol: symbolComment by ExE Boss (@ExE-Boss)
(property) customSymbol: symbolExE-Boss commentedon Mar 10, 2021
Looks like this got fixed at some point in TypeScript 4.1 with the changes to
module.exportshandling.weswigham commentedon Mar 10, 2021
Yeah, #42655 probably got this as a drive by?
ExE-Boss commentedon Mar 11, 2021
Note that this breaks if you do:
Workbench Repro