René's URL Explorer Experiment


Title: Incorrect operator precedence when using private fields with nullish coalescing assignment for targets <= es2021 · Issue #61109 · microsoft/TypeScript · GitHub

Open Graph Title: Incorrect operator precedence when using private fields with nullish coalescing assignment for targets <= es2021 · Issue #61109 · microsoft/TypeScript

X Title: Incorrect operator precedence when using private fields with nullish coalescing assignment for targets <= es2021 · Issue #61109 · microsoft/TypeScript

Description: 🔎 Search Terms "nullish coalescing assignment", "private properties", "private fields", "target es2021", "operator precedence" 🕗 Version & Regression Information This changed between versions 3.9.7 and 4.0.5 (with the introduction of nul...

Open Graph Description: 🔎 Search Terms "nullish coalescing assignment", "private properties", "private fields", "target es2021", "operator precedence" 🕗 Version & Regression Information This changed between versions 3.9.7...

X Description: 🔎 Search Terms "nullish coalescing assignment", "private properties", "private fields", "target es2021", "operator precedence" 🕗 Version & Regr...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect operator precedence when using private fields with nullish coalescing assignment for targets \u003c= es2021","articleBody":"### 🔎 Search Terms\n\n\"nullish coalescing assignment\", \"private properties\", \"private fields\", \"target es2021\", \"operator precedence\"\n\n### 🕗 Version & Regression Information\n\n- This changed between versions 3.9.7 and 4.0.5\n\n(with the introduction of nullish coalescing assignment)\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?noUnusedLocals=true&noUnusedParameters=true&target=8&jsx=0&noFallthroughCasesInSwitch=true&useUnknownInCatchVariables=true&ts=5.8.0-dev.20250204&ssl=6&ssc=1&pln=9&pc=1#code/MYGwhgzhAEDCIwN4ChpugBwK4CMQEtgAFAJwHsMAuaAOywFscBTE6AH2ixoBMmAzfDSbcA3KnQBiDCXwA3MABcmpCtTqMW7Tj36DhY8WhpkVeJvQAUASmgp096AHpH0ACoALfDADuZEgGsYSGgmAA8MJmAlbmolEhowEgBPEPCSJih8MhpoMB5oBXcmWiwQAgh3aGAyMBAM4EEAc0MHZ1zMxpp6JhoFXPSQ+RAsRWFoGUb3BQBaBTJpur4FABpoCDICooKWBOTU6QyILJyvFvs2xvIsCO5c-K9obJAUpiGR6OhvIpyAA0KvAB02DwhBUGB+0AedDKXncALO6H+ECBuAIxHIGGgAH4sQBeaB8WoQYpY2ivFgeLzWaDUACMACYAMxiBzoNqUnx+QKrZjAMBYYmfYoC4oYRI9QoZDKUBFoJEAqQyeRKMHYvHQCyEhAksmyCmeCDU6j0gAMVhZ6AAvsgWtIyGZLDY7KynC4OQSwPgEDzIvzBZLoD8cbiIQ8FCQ8hBwB85rlAziIV9CJV3MEABIASQA4mmAKIAJVlrsw6WAwh6Zc2eU2xTiuxeaUOx3hLs2gMVclGquDHu12N1+qpNmNJotaGt1uQ1Ro6zqANATES1gM04gfVY+KE3jgCDEJABxlMdUde4PJnIDuXNtXZDnIDIjQsAHJjCX7ce1htCSQn+abfu7UvP8p2yWcmABe9HxfDZAI-RRcjKX8DD4LgomOAcSA5aw1HJVhnTldxyG3LdoFzEhyBIZ93QqMhSludJamecZFzKFIhD1VhUwwCIaAAQiQ5BLSAA\n\n(BTW: run it to see the problem)\n\n### 💻 Code\n\n```ts\nclass Cls {\n    publicProp: number | undefined;\n    #privateProp: number | undefined;\n\n    noProblem() {\n        // This works as expected: ternary expression and the nullish coalescing\n        // assignment are evaluated right-to-left, so the ternary expression is\n        // grouped and is only evaluated when `this.publicProp` is nullish.\n        this.publicProp ??= false ? neverThis() : 123;\n        // This works, because we use parentheses:\n        this.#privateProp ??= (false ? neverThis() : 20);\n    }\n\n    problem() {\n        // This fails, because the `??=` is translated to a `??` which has HIGHER\n        // precedence than the ternary expression.\n        this.#privateProp ??= false ? neverThis() : 20;\n    }\n}\n\nconsole.clear();\n\nconst r = new Cls;\nr.noProblem();\nr.noProblem();\n\nconsole.log('no problem so far');\n\nr.problem();\n\nconsole.log('no problem at all');\n\nfunction neverThis(): never {\n    throw new Error('This should really really never happen!');\n}\n```\n\n\n### 🙁 Actual behavior\n\nThe statement `this.#privateProp ??= false ? neverThis() : 20;` is translated into:\n```js\n__classPrivateFieldSet(this, _Cls_privateProp, __classPrivateFieldGet(this, _Cls_privateProp, \"f\") ?? false ? neverThis() : 20, \"f\");\n```\n\nThe relevant piece here is:\n```js\n__classPrivateFieldGet(this, _Cls_privateProp, \"f\") ?? false ? neverThis() : 20\n```\n\nwhich is equivalent to:\n```js\n(__classPrivateFieldGet(this, _Cls_privateProp, \"f\") ?? false) ? neverThis() : 20\n```\n\nBut it should have been:\n```js\n__classPrivateFieldGet(this, _Cls_privateProp, \"f\") ?? (false ? neverThis() : 20)\n```\n\n### 🙂 Expected behavior\n\nExpected correct operator precedence in transpiled code.\n\n### Additional information about the issue\n\nThis is no issue on targets greater than es2021, because of the native support of private fields.","author":{"url":"https://github.com/pavadeli","@type":"Person","name":"pavadeli"},"datePublished":"2025-02-04T08:54:14Z","url":"https://github.com/microsoft/TypeScript/issues/61109"}

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:7ddae0f1-87d6-d525-d8ab-a257cfea674e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD62E:1F7384:9FBF7A:D4FE41:6B00E7E0
html-safe-nonce7ef20596674ea57130879d8a2ecc768d21a8d55eb68c0d11ac097e118d55d9c1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjJFOjFGNzM4NDo5RkJGN0E6RDRGRTQxOjZCMDBFN0UwIiwidmlzaXRvcl9pZCI6IjcyMjU1NTUyNDQ4NjI3MjgxNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacef748857db279e820640a82cbf1be4ce11fd60b786376945b14df82daaddc298
hovercard-subject-tagissue:2829518903
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/61109/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1d53bd12ef87c0d222ee05ef5c095267a0cd3e122348fa684f78a93b9d68afed/microsoft/TypeScript/issues/61109
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1d53bd12ef87c0d222ee05ef5c095267a0cd3e122348fa684f78a93b9d68afed/microsoft/TypeScript/issues/61109
og:image:alt🔎 Search Terms "nullish coalescing assignment", "private properties", "private fields", "target es2021", "operator precedence" 🕗 Version & Regression Information This changed between versions 3.9.7...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepavadeli
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
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
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/61109#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F61109
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%2F61109
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/61109
Reloadhttps://github.com/microsoft/TypeScript/issues/61109
Reloadhttps://github.com/microsoft/TypeScript/issues/61109
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/61109
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/61109
#61372https://github.com/microsoft/TypeScript/pull/61372
Incorrect operator precedence when using private fields with nullish coalescing assignment for targets <= es2021https://github.com/microsoft/TypeScript/issues/61109#top
#61372https://github.com/microsoft/TypeScript/pull/61372
https://github.com/rbuckton
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
TypeScript 5.8.0https://github.com/microsoft/TypeScript/milestone/212
https://github.com/pavadeli
Paco van der Linden (pavadeli)https://github.com/pavadeli
on Feb 4, 2025https://github.com/microsoft/TypeScript/issues/61109#issue-2829518903
https://www.typescriptlang.org/play/?noUnusedLocals=true&noUnusedParameters=true&target=8&jsx=0&noFallthroughCasesInSwitch=true&useUnknownInCatchVariables=true&ts=5.8.0-dev.20250204&ssl=6&ssc=1&pln=9&pc=1#code/MYGwhgzhAEDCIwN4ChpugBwK4CMQEtgAFAJwHsMAuaAOywFscBTE6AH2ixoBMmAzfDSbcA3KnQBiDCXwA3MABcmpCtTqMW7Tj36DhY8WhpkVeJvQAUASmgp096AHpH0ACoALfDADuZEgGsYSGgmAA8MJmAlbmolEhowEgBPEPCSJih8MhpoMB5oBXcmWiwQAgh3aGAyMBAM4EEAc0MHZ1zMxpp6JhoFXPSQ+RAsRWFoGUb3BQBaBTJpur4FABpoCDICooKWBOTU6QyILJyvFvs2xvIsCO5c-K9obJAUpiGR6OhvIpyAA0KvAB02DwhBUGB+0AedDKXncALO6H+ECBuAIxHIGGgAH4sQBeaB8WoQYpY2ivFgeLzWaDUACMACYAMxiBzoNqUnx+QKrZjAMBYYmfYoC4oYRI9QoZDKUBFoJEAqQyeRKMHYvHQCyEhAksmyCmeCDU6j0gAMVhZ6AAvsgWtIyGZLDY7KynC4OQSwPgEDzIvzBZLoD8cbiIQ8FCQ8hBwB85rlAziIV9CJV3MEABIASQA4mmAKIAJVlrsw6WAwh6Zc2eU2xTiuxeaUOx3hLs2gMVclGquDHu12N1+qpNmNJotaGt1uQ1Ro6zqANATES1gM04gfVY+KE3jgCDEJABxlMdUde4PJnIDuXNtXZDnIDIjQsAHJjCX7ce1htCSQn+abfu7UvP8p2yWcmABe9HxfDZAI-RRcjKX8DD4LgomOAcSA5aw1HJVhnTldxyG3LdoFzEhyBIZ93QqMhSludJamecZFzKFIhD1VhUwwCIaAAQiQ5BLSAAhttps://www.typescriptlang.org/play/?noUnusedLocals=true&noUnusedParameters=true&target=8&jsx=0&noFallthroughCasesInSwitch=true&useUnknownInCatchVariables=true&ts=5.8.0-dev.20250204&ssl=6&ssc=1&pln=9&pc=1#code/MYGwhgzhAEDCIwN4ChpugBwK4CMQEtgAFAJwHsMAuaAOywFscBTE6AH2ixoBMmAzfDSbcA3KnQBiDCXwA3MABcmpCtTqMW7Tj36DhY8WhpkVeJvQAUASmgp096AHpH0ACoALfDADuZEgGsYSGgmAA8MJmAlbmolEhowEgBPEPCSJih8MhpoMB5oBXcmWiwQAgh3aGAyMBAM4EEAc0MHZ1zMxpp6JhoFXPSQ+RAsRWFoGUb3BQBaBTJpur4FABpoCDICooKWBOTU6QyILJyvFvs2xvIsCO5c-K9obJAUpiGR6OhvIpyAA0KvAB02DwhBUGB+0AedDKXncALO6H+ECBuAIxHIGGgAH4sQBeaB8WoQYpY2ivFgeLzWaDUACMACYAMxiBzoNqUnx+QKrZjAMBYYmfYoC4oYRI9QoZDKUBFoJEAqQyeRKMHYvHQCyEhAksmyCmeCDU6j0gAMVhZ6AAvsgWtIyGZLDY7KynC4OQSwPgEDzIvzBZLoD8cbiIQ8FCQ8hBwB85rlAziIV9CJV3MEABIASQA4mmAKIAJVlrsw6WAwh6Zc2eU2xTiuxeaUOx3hLs2gMVclGquDHu12N1+qpNmNJotaGt1uQ1Ro6zqANATES1gM04gfVY+KE3jgCDEJABxlMdUde4PJnIDuXNtXZDnIDIjQsAHJjCX7ce1htCSQn+abfu7UvP8p2yWcmABe9HxfDZAI-RRcjKX8DD4LgomOAcSA5aw1HJVhnTldxyG3LdoFzEhyBIZ93QqMhSludJamecZFzKFIhD1VhUwwCIaAAQiQ5BLSAA
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Feb 4, 2025https://github.com/microsoft/TypeScript/issues/61109#event-16181989229
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Ron Buckton (rbuckton)https://github.com/rbuckton
on Feb 4, 2025https://github.com/microsoft/TypeScript/issues/61109#event-16181989852
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 5.8.0https://github.com/microsoft/TypeScript/milestone/212
on Feb 4, 2025https://github.com/microsoft/TypeScript/issues/61109#event-16181990648
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
on Apr 11, 2025https://github.com/microsoft/TypeScript/issues/61109#event-17220622494
Jake Bailey (jakebailey)https://github.com/jakebailey
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#61372https://github.com/microsoft/TypeScript/pull/61372
on Jun 30, 2025https://github.com/microsoft/TypeScript/issues/61109#event-18394625064
microsofthttps://github.com/microsoft
on Jan 7, 2026https://github.com/microsoft/TypeScript/issues/61109#event-21905524160
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/61109
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/61109
Ron Buckton (rbuckton)https://github.com/rbuckton
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
TypeScript 5.8.0https://github.com/microsoft/TypeScript/milestone/212
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.