René's URL Explorer Experiment


Title: Cannot create a unique symbol at each function call · Issue #40106 · microsoft/TypeScript · GitHub

Open Graph Title: Cannot create a unique symbol at each function call · Issue #40106 · microsoft/TypeScript

X Title: Cannot create a unique symbol at each function call · Issue #40106 · microsoft/TypeScript

Description: Search Terms Symbol, unique, generated, function call Suggestion With two functions returning unique symbol. declare function randomSymbol(): { readonly id: unique symbol }; declare function randomSymbol2(): { readonly id: unique symbol ...

Open Graph Description: Search Terms Symbol, unique, generated, function call Suggestion With two functions returning unique symbol. declare function randomSymbol(): { readonly id: unique symbol }; declare function random...

X Description: Search Terms Symbol, unique, generated, function call Suggestion With two functions returning unique symbol. declare function randomSymbol(): { readonly id: unique symbol }; declare function random...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/40106

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot create a unique symbol at each function call","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the FAQ, especially the \"Common Feature Requests\" section: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\nSymbol, unique, generated, function call\r\n\r\n## Suggestion\r\n\r\nWith two functions returning `unique symbol`.\r\n\r\n```ts\r\ndeclare function randomSymbol(): { readonly id: unique symbol };\r\ndeclare function randomSymbol2(): { readonly id: unique symbol };\r\n```\r\n\r\nWhen comparing the symbol types when calling these two functions, we get a (correct) error from the compiler telling us that these types are incompatible.\r\n\r\n```ts\r\nconst a = randomSymbol();\r\nconst b = randomSymbol2();\r\n\r\na.id === a.id;\r\na.id === b.id; // TS ERROR: Expected behaviour. 👍 \r\n```\r\n\r\nIf we call the same function two times though, the types are the same.\r\n\r\n```ts\r\nconst a = randomSymbol();\r\nconst b = randomSymbol();\r\n\r\na.id === a.id;\r\na.id === b.id; // NO ERROR: But I would expect these two types to be different too 👎 \r\n```\r\n\r\nI understand that this can be expected in some cases, though there is currently no way to tell the compiler to generate a different unique symbol for each function call.\r\n\r\n## Use Cases\r\n\r\nMy current use-case is for creating two objects using the same constructor, that are structurally identical, but that would not be compatible between them (kind of opaque types).\r\n\r\nMaybe this should be through the usage of a new keyword to prevent compatibility issues with existing codebases.\r\n\r\n## Examples\r\n\r\nhttps://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXxilWBwFsBlAT1ICMcIAKASgC54BvAkKE1CS+FmBs0WAI7IEAZ2p0I8AL4BuAFChIsBCnTY8BIiQqz6AJmZtOcHnn6Dh8UROnH5ylSvYr48MHikZ4KHgAXn1iMipaemZVb19Uf3gaELDDSLkzJlUvQIA6IRDg0Kh84Fi8gqLQmlKleAB6evgAeQBpFQV3Tzi-AKDQwnCjKMYsnPjE5IGDCJcY928SyqKKspyl4ELq2oamgEl4AHccZAhNkAAPAAdwAIwACxApBAxj+AxKG6l3nCSEYCwiEQIDgqDuOBwHRUQA\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [X] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [X] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [X] This could be implemented without emitting different JS based on the types of the expressions\r\n* [X] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [X] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n","author":{"url":"https://github.com/kube","@type":"Person","name":"kube"},"datePublished":"2020-08-18T03:07:54Z","url":"https://github.com/microsoft/TypeScript/issues/40106"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:bd95422d-f16f-b374-70d0-5dc1151b80ff
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB416:20D380:3FB573:5798D0:6B046D7B
html-safe-nonceb6d5096136207763966ad432889fe194b9bb64ea9620e13e536b533f78201ab3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDE2OjIwRDM4MDozRkI1NzM6NTc5OEQwOjZCMDQ2RDdCIiwidmlzaXRvcl9pZCI6IjEwNDQxOTQ4OTAzNDAzOTY0MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac81bc892a152fba11e39b84c12bde51884fe619cf4442840bb858c7b5ffb17142
hovercard-subject-tagissue:680652996
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/40106/issue_layout
twitter:imagehttps://opengraph.githubassets.com/73263000edd90a157a77f81fae8b0eec72e05acd7cedf02116fdc0e6daf59a4c/microsoft/TypeScript/issues/40106
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/73263000edd90a157a77f81fae8b0eec72e05acd7cedf02116fdc0e6daf59a4c/microsoft/TypeScript/issues/40106
og:image:altSearch Terms Symbol, unique, generated, function call Suggestion With two functions returning unique symbol. declare function randomSymbol(): { readonly id: unique symbol }; declare function random...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekube
hostnamegithub.com
expected-hostnamegithub.com
Noneae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecfb5f24c6e01d85f70804652a5107e5cac03a161
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/40106#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F40106
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F40106
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/40106
Reloadhttps://github.com/microsoft/TypeScript/issues/40106
Reloadhttps://github.com/microsoft/TypeScript/issues/40106
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests319 (319)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/40106
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/40106
Cannot create a unique symbol at each function callhttps://github.com/microsoft/TypeScript/issues/40106#top
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
https://github.com/kube
Chris Feijoo (kube)https://github.com/kube
on Aug 18, 2020https://github.com/microsoft/TypeScript/issues/40106#issue-680652996
https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXxilWBwFsBlAT1ICMcIAKASgC54BvAkKE1CS+FmBs0WAI7IEAZ2p0I8AL4BuAFChIsBCnTY8BIiQqz6AJmZtOcHnn6Dh8UROnH5ylSvYr48MHikZ4KHgAXn1iMipaemZVb19Uf3gaELDDSLkzJlUvQIA6IRDg0Kh84Fi8gqLQmlKleAB6evgAeQBpFQV3Tzi-AKDQwnCjKMYsnPjE5IGDCJcY928SyqKKspyl4ELq2oamgEl4AHccZAhNkAAPAAdwAIwACxApBAxj+AxKG6l3nCSEYCwiEQIDgqDuOBwHRUQAhttps://www.typescriptlang.org/play#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXxilWBwFsBlAT1ICMcIAKASgC54BvAkKE1CS+FmBs0WAI7IEAZ2p0I8AL4BuAFChIsBCnTY8BIiQqz6AJmZtOcHnn6Dh8UROnH5ylSvYr48MHikZ4KHgAXn1iMipaemZVb19Uf3gaELDDSLkzJlUvQIA6IRDg0Kh84Fi8gqLQmlKleAB6evgAeQBpFQV3Tzi-AKDQwnCjKMYsnPjE5IGDCJcY928SyqKKspyl4ELq2oamgEl4AHccZAhNkAAPAAdwAIwACxApBAxj+AxKG6l3nCSEYCwiEQIDgqDuOBwHRUQA
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
on Aug 20, 2020https://github.com/microsoft/TypeScript/issues/40106#event-3675849293
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 20, 2020https://github.com/microsoft/TypeScript/issues/40106#issuecomment-677741032
https://github.com/typescript-bot
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
on Aug 22, 2020https://github.com/microsoft/TypeScript/issues/40106#issuecomment-678686401
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 22, 2020https://github.com/microsoft/TypeScript/issues/40106#event-3682279518
https://github.com/ExE-Boss
ExE Boss (ExE-Boss)https://github.com/ExE-Boss
on Jan 25, 2021https://github.com/microsoft/TypeScript/issues/40106#issuecomment-766671991
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
#37469https://github.com/microsoft/TypeScript/issues/37469
https://github.com/jcalz
Joe Calzaretta (jcalz)https://github.com/jcalz
on Feb 6, 2022https://github.com/microsoft/TypeScript/issues/40106#issuecomment-1030916975
#37469https://github.com/microsoft/TypeScript/issues/37469
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/40106#event-20417014975
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/40106
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/40106
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.