René's URL Explorer Experiment


Title: unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microsoft/TypeScript · GitHub

Open Graph Title: unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microsoft/TypeScript

X Title: unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microsoft/TypeScript

Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microsoft/TypeScript

Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microso...

X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microso...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"unique symbol incorrectly widens to symbol when assigning to a const or readonly property","articleBody":"**Search Terms:** \r\nunique symbol, literal, widen, reassign, const, readonly\r\n\r\n**Code**\r\n\r\n```ts\r\nconst t1 = Symbol(\"t1\")\r\nconst t1Copy = t1\r\nconst result1: typeof t1 = t1 // no error\r\nconst result2: typeof t1 = t1Copy // error: type symbol not assignable to unique symbol\r\n\r\nclass T2 {\r\n    static readonly sym = Symbol(\"T2\")\r\n    readonly kind = T2.sym\r\n}\r\n\r\nconst inst = new T2()\r\nconst result3: typeof T2.sym = T2.sym // no error\r\nconst result4: typeof T2.sym = inst.kind // error: type symbol not assignable to unique symbol\r\n\r\ndeclare function genericIdentity\u003cT>(arg: T): T\r\nconst unexpectedError: typeof t1 = genericIdentity(t1)\r\n\r\ndeclare function genericSymbolNested\u003cT extends symbol>(arg: T): { prop: T }\r\nconst unexpectedError2: { prop: typeof t1 } = genericSymbolNested(t1)\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors. `t1Copy` and `inst.kind` should retain their respective literal `unique symbol` types the same way string literals would because they are declared with `const` and `readonly`.\r\n\r\n**Actual behavior:**\r\nErrors on `result2` and `result4` because `t1Copy` and `inst.kind` are widened to `symbol`. When assigning a `unique symbol` variable to a new variable the type is always widened to `symbol` unless an explicit type annotation is added.\r\n\r\n**Playground Link:** \r\n[Link](https://www.typescriptlang.org/play/#src=const%20t1%20%3D%20Symbol(%22t1%22)%0D%0Aconst%20t1Copy%20%3D%20t1%0D%0Aconst%20result1%3A%20typeof%20t1%20%3D%20t1%20%2F%2F%20no%20error%0D%0Aconst%20result2%3A%20typeof%20t1%20%3D%20t1Copy%20%2F%2F%20error%3A%20type%20symbol%20not%20assignable%20to%20unique%20symbol%0D%0A%0D%0Aclass%20T2%20%7B%0D%0A%20%20%20%20static%20readonly%20sym%20%3D%20Symbol(%22T2%22)%0D%0A%20%20%20%20readonly%20kind%20%3D%20T2.sym%0D%0A%7D%0D%0A%0D%0Aconst%20inst%20%3D%20new%20T2()%0D%0Aconst%20result3%3A%20typeof%20T2.sym%20%3D%20T2.sym%20%2F%2F%20no%20error%0D%0Aconst%20result4%3A%20typeof%20T2.sym%20%3D%20inst.kind%20%2F%2F%20error%3A%20type%20symbol%20not%20assignable%20to%20unique%20symbol%0D%0A%0D%0Adeclare%20function%20genericIdentity%3CT%3E(arg%3A%20T)%3A%20T%0D%0Aconst%20unexpectedError%3A%20typeof%20t1%20%3D%20genericIdentity(t1)%0D%0A%0D%0Adeclare%20function%20genericSymbolNested%3CT%20extends%20symbol%3E(arg%3A%20T)%3A%20%7B%20prop%3A%20T%20%7D%0D%0Aconst%20unexpectedError2%3A%20%7B%20prop%3A%20typeof%20t1%20%7D%20%3D%20genericSymbolNested(t1)%0D%0A)\r\n\r\n**Related Issues:**\r\nDid not notice any similar bug reports, but the design notes from #17501 seem to confirm that the current behavior is a bug:\r\n\r\n> - Like literal types, these types contain \"freshness\" which can be widened away to produce a \"regular\" type.\r\n> - When you alias a symbolic const with another const, it has the type `typeof [[that original variable]]`.\r\n\r\nWhich implies they should work like other literal types which would not be widened in the example above.","author":{"url":"https://github.com/kpdonn","@type":"Person","name":"kpdonn"},"datePublished":"2018-04-09T09:03:43Z","url":"https://github.com/microsoft/TypeScript/issues/23263"}

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/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:0ff5c894-1e59-273a-6bda-99ea4109e3a3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9FB8:134361:D5690A:119E7D7:6B00F973
html-safe-nonce2bd73bd635d6c8eda62d65fb583de603425b10dbb14ca4eec70dc405b0f55878
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkI4OjEzNDM2MTpENTY5MEE6MTE5RTdENzo2QjAwRjk3MyIsInZpc2l0b3JfaWQiOiIyNDU3MTg0Mzk0NjM4MTE0NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf135bf18b62872e449d1b71c6c025aadbd8e54f4f9104f93cf3601fffe4efc1c
hovercard-subject-tagrepository:20929025
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/microsoft/TypeScript/issues/23263
twitter:imagehttps://opengraph.githubassets.com/7f74c95cbe889dbb3d9b1bf9b33e028a73710cb2fdd6519734f41a069c8c2bfa/microsoft/TypeScript
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7f74c95cbe889dbb3d9b1bf9b33e028a73710cb2fdd6519734f41a069c8c2bfa/microsoft/TypeScript
og:image:altTypeScript is a superset of JavaScript that compiles to clean JavaScript output. - unique symbol incorrectly widens to symbol when assigning to a const or readonly property · Issue #23263 · microso...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187
turbo-cache-controlno-cache
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
release7dafd017fb7809a839c443dba08622af38e63c09
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/23263#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F23263
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%2F23263
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/23263
Reloadhttps://github.com/microsoft/TypeScript/issues/23263
Reloadhttps://github.com/microsoft/TypeScript/issues/23263
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/23263
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/23263
unique symbol incorrectly widens to symbol when assigning to a const or readonly propertyhttps://github.com/microsoft/TypeScript/issues/23263#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/kpdonn
Kevin Donnelly (kpdonn)https://github.com/kpdonn
on Apr 9, 2018https://github.com/microsoft/TypeScript/issues/23263#issue-312449648
Linkhttps://www.typescriptlang.org/play/#src=const%20t1%20%3D%20Symbol(%22t1%22)%0D%0Aconst%20t1Copy%20%3D%20t1%0D%0Aconst%20result1%3A%20typeof%20t1%20%3D%20t1%20%2F%2F%20no%20error%0D%0Aconst%20result2%3A%20typeof%20t1%20%3D%20t1Copy%20%2F%2F%20error%3A%20type%20symbol%20not%20assignable%20to%20unique%20symbol%0D%0A%0D%0Aclass%20T2%20%7B%0D%0A%20%20%20%20static%20readonly%20sym%20%3D%20Symbol(%22T2%22)%0D%0A%20%20%20%20readonly%20kind%20%3D%20T2.sym%0D%0A%7D%0D%0A%0D%0Aconst%20inst%20%3D%20new%20T2()%0D%0Aconst%20result3%3A%20typeof%20T2.sym%20%3D%20T2.sym%20%2F%2F%20no%20error%0D%0Aconst%20result4%3A%20typeof%20T2.sym%20%3D%20inst.kind%20%2F%2F%20error%3A%20type%20symbol%20not%20assignable%20to%20unique%20symbol%0D%0A%0D%0Adeclare%20function%20genericIdentity%3CT%3E(arg%3A%20T)%3A%20T%0D%0Aconst%20unexpectedError%3A%20typeof%20t1%20%3D%20genericIdentity(t1)%0D%0A%0D%0Adeclare%20function%20genericSymbolNested%3CT%20extends%20symbol%3E(arg%3A%20T)%3A%20%7B%20prop%3A%20T%20%7D%0D%0Aconst%20unexpectedError2%3A%20%7B%20prop%3A%20typeof%20t1%20%7D%20%3D%20genericSymbolNested(t1)%0D%0A
#17501https://github.com/microsoft/TypeScript/issues/17501
https://github.com/kpdonn
Kevin Donnelly (kpdonn)https://github.com/kpdonn
on Apr 10, 2018https://github.com/microsoft/TypeScript/issues/23263#issuecomment-380263967
Playground linkhttps://www.typescriptlang.org/play/#src=declare%20const%20sym%3A%20unique%20symbol%0D%0A%0D%0Adeclare%20function%20genericIdentity%3CT%3E(arg%3A%20T)%3A%20T%0D%0Aconst%20unexpectedError%3A%20typeof%20sym%20%3D%20genericIdentity(sym)%0D%0A%0D%0Adeclare%20function%20genericSymbolNested%3CT%20extends%20symbol%3E(arg%3A%20T)%3A%20%7B%20prop%3A%20T%20%7D%0D%0Aconst%20unexpectedError2%3A%20%7B%20prop%3A%20typeof%20sym%20%7D%20%3D%20genericSymbolNested(sym)%0D%0A%0D%0A%2F%2F%20Compare%20with%20the%20following%20equivalent%20code%20using%20literal%20strings%3A%0D%0A%0D%0Adeclare%20const%20literalString%3A%20%22literal%22%0D%0Aconst%20noErrorWithString%3A%20typeof%20literalString%20%3D%20genericIdentity(literalString)%0D%0A%0D%0Adeclare%20function%20genericStringNested%3CT%20extends%20string%3E(arg%3A%20T)%3A%20%7B%20prop%3A%20T%20%7D%0D%0Aconst%20noErrorWithString2%3A%20%7B%20prop%3A%20typeof%20literalString%20%7D%20%3D%20genericStringNested(literalString)%0D%0A
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Jul 18, 2018https://github.com/microsoft/TypeScript/issues/23263#issuecomment-406097334
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
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 Jul 18, 2018https://github.com/microsoft/TypeScript/issues/23263#event-1741307506
https://github.com/falsandtru
falsandtru (falsandtru)https://github.com/falsandtru
on Jul 19, 2018https://github.com/microsoft/TypeScript/issues/23263#issuecomment-406136814
https://github.com/kpdonn
Kevin Donnelly (kpdonn)https://github.com/kpdonn
on Jul 19, 2018https://github.com/microsoft/TypeScript/issues/23263#issuecomment-406238419
falsandtru (@falsandtru)https://github.com/falsandtru
#17501https://github.com/microsoft/TypeScript/issues/17501
https://github.com/typescript-bot
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
on Jul 30, 2018https://github.com/microsoft/TypeScript/issues/23263#issuecomment-408923953
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 Jul 30, 2018https://github.com/microsoft/TypeScript/issues/23263#event-1760621589
https://github.com/falsandtru
falsandtru (falsandtru)https://github.com/falsandtru
on Jan 1, 2020https://github.com/microsoft/TypeScript/issues/23263#issuecomment-570067101
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/23263#event-20415639014
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/23263
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/23263
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

Viewport: width=device-width


URLs of crawlers that visited me.