René's URL Explorer Experiment


Title: Private variable in a class is treated as public in the transpiled code · Issue #9733 · microsoft/TypeScript · GitHub

Open Graph Title: Private variable in a class is treated as public in the transpiled code · Issue #9733 · microsoft/TypeScript

X Title: Private variable in a class is treated as public in the transpiled code · Issue #9733 · microsoft/TypeScript

Description: Correct me if I am wrong. There is something fundamentally wrong in the transpilation. I created a class called Person with an intention to keep the name private to the class and expose it via a method. The transpiled code is making the ...

Open Graph Description: Correct me if I am wrong. There is something fundamentally wrong in the transpilation. I created a class called Person with an intention to keep the name private to the class and expose it via a me...

X Description: Correct me if I am wrong. There is something fundamentally wrong in the transpilation. I created a class called Person with an intention to keep the name private to the class and expose it via a me...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Private variable in a class is treated as public in the transpiled code","articleBody":"Correct me if I am wrong. There is something fundamentally wrong in the transpilation.\n\nI created a class called Person with an intention to keep the name private to the class and expose it via a method. The transpiled code is making the field ( defined as private)  public, however , in typescript code - it prevents the direct access of private fields outside the constructor function and prototype\n\nMy get method is added to the prototype. This is wrong. It should be part of the function constructor itself. \n\nIs there a way to get this in transpiler ?\n\nPlease find the transpiled code and what it should have been ( ideally)\n\nTranspiled code\n\n'use strict';\nvar Person = (function () {\n    function Person(name) {\n        this._name = name;\n    }\n    ;\n    Person.prototype.getName = function () {\n        return 'Name : ' + this._name;\n    };\n    return Person;\n}());\nvar p = new Person('John');\nconsole.log(p.getName());\n\nWhat it should have been ideally\n\n'use strict';\nvar Person = (function () {\n\nlet _name;\n    function Person(name) {\n     _name  = name;\n\n```\n this.getName = function () {\n    return 'Name : ' + _name;\n};\n};\n\nreturn Person;\n```\n\n}());\nvar p = new Person('John');\nconsole.log(p.getName());\nconsole.log(p._name); //not accessible\n","author":{"url":"https://github.com/smangalath","@type":"Person","name":"smangalath"},"datePublished":"2016-07-14T12:28:43Z","url":"https://github.com/microsoft/TypeScript/issues/9733"}

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:78209518-075d-59a3-ae25-e328b192066e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBEA4:E3C4F:78273C:9AF69E:6B00E69E
html-safe-nonce6f5e4187184c82cad8cfc3c4eda63ad267d0038a9cc95fd698d69c511eca79bf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUE0OkUzQzRGOjc4MjczQzo5QUY2OUU6NkIwMEU2OUUiLCJ2aXNpdG9yX2lkIjoiNDU5NDg0OTUyOTM3ODk1Njk1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac69b2735574bafd32bc680bfd731d4e37019d4b2c278bc6cc0bb7c3dfbb121634
hovercard-subject-tagissue:165550138
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/9733/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4fe808c4a9cea6c8e2ddb5e0664711fbe1bd8f0c1ec6ad41bf6a1b8713c3e34e/microsoft/TypeScript/issues/9733
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4fe808c4a9cea6c8e2ddb5e0664711fbe1bd8f0c1ec6ad41bf6a1b8713c3e34e/microsoft/TypeScript/issues/9733
og:image:altCorrect me if I am wrong. There is something fundamentally wrong in the transpilation. I created a class called Person with an intention to keep the name private to the class and expose it via a me...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesmangalath
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/9733#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F9733
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%2F9733
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/9733
Reloadhttps://github.com/microsoft/TypeScript/issues/9733
Reloadhttps://github.com/microsoft/TypeScript/issues/9733
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/9733
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/9733
Private variable in a class is treated as public in the transpiled codehttps://github.com/microsoft/TypeScript/issues/9733#top
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
https://github.com/smangalath
smangalathhttps://github.com/smangalath
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#issue-165550138
https://github.com/sgrtho
Thomas Schön (sgrtho)https://github.com/sgrtho
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232654323
https://github.com/smangalath
smangalathhttps://github.com/smangalath
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232655812
https://github.com/sgrtho
Thomas Schön (sgrtho)https://github.com/sgrtho
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232657715
FAQhttps://github.com/Microsoft/TypeScript/wiki/FAQ#you-should-emit-classes-like-this-so-they-have-real-private-members
https://github.com/smangalath
smangalathhttps://github.com/smangalath
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232665934
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#event-723317107
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232735438
#1537https://github.com/microsoft/TypeScript/issues/1537
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 14, 2016https://github.com/microsoft/TypeScript/issues/9733#event-723322417
https://github.com/smangalath
smangalathhttps://github.com/smangalath
on Jul 15, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232830459
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jul 15, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-232839199
https://github.com/smangalath
smangalathhttps://github.com/smangalath
on Jul 15, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-233048377
https://github.com/kitsonk
Kitson Kelly (kitsonk)https://github.com/kitsonk
on Jul 15, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-233055608
https://github.com/sgrtho
Thomas Schön (sgrtho)https://github.com/sgrtho
on Jul 15, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-233083863
https://github.com/kitsonk
Kitson Kelly (kitsonk)https://github.com/kitsonk
on Jul 16, 2016https://github.com/microsoft/TypeScript/issues/9733#issuecomment-233112746
class propertieshttps://github.com/jeffmo/es-class-fields-and-static-properties
microsofthttps://github.com/microsoft
on Jun 19, 2018https://github.com/microsoft/TypeScript/issues/9733#event-1689842600
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/9733
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/9733
DuplicateAn existing issue was already createdhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%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.