-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
TypeScript Version:
3.9.0-dev.20200315
Search Terms:
- object property preserve unique symbol
- module.exports preserve unique symbol
Code
// @target: ES2015
// @module: CommonJS
// @allowJs
// @checkJs
// @noEmit
// @filename: index.js
const customSymbol = 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.js
const customSymbol = 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'.
};
Expected behavior:
// some-module.d.ts
declare const customSymbol: unique symbol;
declare const _default: {
customSymbol: typeof customSymbol;
};
export = _default;
Actual behavior:
// some-module.d.ts
declare const _default: {
customSymbol: symbol;
};
export = _default;
Playground Link:
Related Issues:
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosThis issue has compiler-backed repros: https://aka.ms/ts-reprosNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone