René's URL Explorer Experiment


Title: Property initializers output for non-initialized types · Issue #45076 · microsoft/TypeScript · GitHub

Open Graph Title: Property initializers output for non-initialized types · Issue #45076 · microsoft/TypeScript

X Title: Property initializers output for non-initialized types · Issue #45076 · microsoft/TypeScript

Description: Bug Report This is technically not a bug, given ES Spec, however, I'm filing an issue in case an consideration needs to be made on how to handle with regard to documentation, etc, and/or to provide a solution for people facing the same. ...

Open Graph Description: Bug Report This is technically not a bug, given ES Spec, however, I'm filing an issue in case an consideration needs to be made on how to handle with regard to documentation, etc, and/or to provide...

X Description: Bug Report This is technically not a bug, given ES Spec, however, I'm filing an issue in case an consideration needs to be made on how to handle with regard to documentation, etc, and/or to pro...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Property initializers output for non-initialized types","articleBody":"# Bug Report\r\n\r\nThis is technically not a bug, given ES Spec, however, I'm filing an issue in case an consideration needs to be made on how to handle with regard to documentation, etc, and/or to provide a solution for people facing the same.\r\n\r\n**Issue Summary**\r\n\r\n- ESNext spec seems to call for defining all class fields. This also affects those which are optional or specified with a boom.\r\n- Spec also dictates that property initializers are called _after_ the super call. (https://github.com/tc39/proposal-class-fields)\r\n\r\nThis results in any properties specified in the inherited class that are assigned during the base class constructor to be overwritten, even if they do not have initializer values specified in the inherited class.\r\n\r\nThe behaviour which causes the error can be seen below:\r\n\r\n```ts\r\nclass A {\r\n  a?: string\r\n}\r\n```\r\n\r\nOutput is:\r\n\r\n```js\r\n// target = ESNext\r\nclass A {\r\n  a; // Outputs a statement without initialized value, which is treated as a = undefined;\r\n}\r\n\r\n// target = ES2020\r\nclass A {\r\n}\r\n```\r\n\r\n**Here is a simplified version of how this affected me**\r\n\r\n```ts\r\nabstract class Base\u003cT extends Record\u003cstring, any>> {\r\n  // Single constructor for all derivatives\r\n  constructor(o: Omit\u003cT, typeof Base>) {\r\n    Object.assign(this, o);\r\n  }\r\n}\r\n\r\nclass A extends Base\u003cA> {\r\n  myProp?: string\r\n  myProp2!: string\r\n}\r\n\r\nconst a = new A({ myProp2: 'hello' });\r\n\r\n// ESNext: a = { myProp2: undefined, myProp: undefined }\r\n// ES2020: a = { myProp2: 'hello' }\r\n```\r\n\r\nThe above produces:\r\n\r\n```ts\r\n// TypeScript target=ESNext\r\nclass A extends Base {\r\n  myProp;\r\n  myProp2; // Note the boomed property still gets output here, so it is initialized after the super call - which maybe surprising behaviour\r\n}\r\n\r\n// ES2020 / Babel\r\nclass A extends Base {\r\n}\r\n```\r\n\r\n### 🔎 Search Terms\r\n\r\n- property initializers\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nTS 4.3.5\r\n\r\n## Solution\r\n\r\nFor those facing this issue, simply change property declarations to ambient.\r\n\r\nie:\r\n\r\n```ts\r\nclass A extends Base\u003cA> {\r\n  declare myProp?: string\r\n  declare myProp2: string\r\n}\r\n```","author":{"url":"https://github.com/nonara","@type":"Person","name":"nonara"},"datePublished":"2021-07-16T21:20:19Z","url":"https://github.com/microsoft/TypeScript/issues/45076"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:794ab9d1-2939-ff51-682d-c78ebb278220
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD3AC:E530F:12A35AB:18CC76A:6AED5E1C
html-safe-noncee90a45b3eda7ab29333d2b63182d6648e7cc4dbc8382107770cd2d6323bb8c7d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0FDOkU1MzBGOjEyQTM1QUI6MThDQzc2QTo2QUVENUUxQyIsInZpc2l0b3JfaWQiOiI0NDY5Njg5MjA4ODAwMTA4MDYwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac15f3872723c273315ae4d569b1b7714456ef55f79e802fc5cb233668b6f0aef3
hovercard-subject-tagissue:946603593
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/45076/issue_layout
twitter:imagehttps://opengraph.githubassets.com/12916a76d3ce14976d82e3e2dbed7a295f8255e6b355b29ecf318261d9acccf0/microsoft/TypeScript/issues/45076
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/12916a76d3ce14976d82e3e2dbed7a295f8255e6b355b29ecf318261d9acccf0/microsoft/TypeScript/issues/45076
og:image:altBug Report This is technically not a bug, given ES Spec, however, I'm filing an issue in case an consideration needs to be made on how to handle with regard to documentation, etc, and/or to provide...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenonara
hostnamegithub.com
expected-hostnamegithub.com
None56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11
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
release9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/45076#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F45076
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%2F45076
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/45076
Reloadhttps://github.com/microsoft/TypeScript/issues/45076
Reloadhttps://github.com/microsoft/TypeScript/issues/45076
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues4.9k (4.9k)https://github.com/microsoft/TypeScript/issues
Pull requests298 (298)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/pulse
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/45076
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/45076
Property initializers output for non-initialized typeshttps://github.com/microsoft/TypeScript/issues/45076#top
DocsThe issue relates to how you learn TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Docs%22
https://github.com/nonara
Ron Spickenagel (nonara)https://github.com/nonara
on Jul 16, 2021https://github.com/microsoft/TypeScript/issues/45076#issue-946603593
https://github.com/tc39/proposal-class-fieldshttps://github.com/tc39/proposal-class-fields
https://github.com/jcalz
Joe Calzaretta (jcalz)https://github.com/jcalz
on Jul 18, 2021https://github.com/microsoft/TypeScript/issues/45076#issuecomment-881991226
the --useDefineForClassFields compiler flaghttps://www.typescriptlang.org/tsconfig#useDefineForClassFields
#42663https://github.com/microsoft/TypeScript/pull/42663
this commenthttps://github.com/microsoft/TypeScript/issues/34787#issuecomment-849379479
#34787https://github.com/microsoft/TypeScript/issues/34787
the TypeScript-website issue listhttps://github.com/microsoft/TypeScript-website/issues
https://github.com/nonara
Ron Spickenagel (nonara)https://github.com/nonara
on Jul 18, 2021https://github.com/microsoft/TypeScript/issues/45076#issuecomment-882007485
#42663https://github.com/microsoft/TypeScript/pull/42663
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Jul 18, 2021https://github.com/microsoft/TypeScript/issues/45076#issuecomment-882044239
#42663https://github.com/microsoft/TypeScript/pull/42663
#34787https://github.com/microsoft/TypeScript/issues/34787
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Jul 18, 2021https://github.com/microsoft/TypeScript/issues/45076#issuecomment-882100083
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
DocsThe issue relates to how you learn TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Docs%22
on Jul 21, 2021https://github.com/microsoft/TypeScript/issues/45076#event-5052128347
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/45076
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/45076
DocsThe issue relates to how you learn TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Docs%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.