René's URL Explorer Experiment


Title: Add a visibility mechanism similar to `friend` or `InternalsVisibleTo` · Issue #35554 · microsoft/TypeScript · GitHub

Open Graph Title: Add a visibility mechanism similar to `friend` or `InternalsVisibleTo` · Issue #35554 · microsoft/TypeScript

X Title: Add a visibility mechanism similar to `friend` or `InternalsVisibleTo` · Issue #35554 · microsoft/TypeScript

Description: Suggestion A way to allow certain other modules to access properties or methods of a class. Use Cases Sometimes, we want other modules (other code) to have access to certain properties or methods, but otherwise the end user not to have a...

Open Graph Description: Suggestion A way to allow certain other modules to access properties or methods of a class. Use Cases Sometimes, we want other modules (other code) to have access to certain properties or methods, ...

X Description: Suggestion A way to allow certain other modules to access properties or methods of a class. Use Cases Sometimes, we want other modules (other code) to have access to certain properties or methods, ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a visibility mechanism similar to `friend` or `InternalsVisibleTo`","articleBody":"\r\n## Suggestion\r\n\r\nA way to allow certain other modules to access properties or methods of a class.\r\n\r\n## Use Cases\r\n\r\nSometimes, we want other modules (other code) to have access to certain properties or methods, but otherwise the end user not to have access to the properties/methods. This is labeled as \"package protected\" or similar terms in other languages.\r\n\r\n## Examples\r\n\r\nThis is how it could work, with some sort of new non-runtime syntax:\r\n\r\n```js\r\nimport SomeClass from './SomeClass'\r\n\r\nexport class Foo {\r\n  visible in SomeClass\r\n  private foo: number = 123\r\n}\r\n```\r\n\r\nor\r\n\r\n```js\r\nimport SomeClass from './SomeClass'\r\n\r\nexport class Foo {\r\n  private foo visible in SomeClass: number = 123\r\n}\r\n```\r\n\r\nor maybe even as a special decorator, globally-declared, virtual decorator\r\n\r\n```js\r\nimport SomeClass from './SomeClass'\r\n\r\nexport class Foo {\r\n  @visibleIn(SomeClass)\r\n  private foo: number = 123\r\n}\r\n```\r\n\r\n`SomeClass` would then be able to access the private property/method: \r\n\r\n```js\r\nimport {Foo} from './Foo'\r\n\r\nexport class SomeClass {\r\n  doSomethingWithFoo(o: Foo) {\r\n    console.log(o.foo) // OK, no type error.\r\n  }\r\n}\r\n```\r\n\r\nThe code inside of `SomeClass` could be allowed to access the private properties. This is great at design time when the author controls the source for both sides, but still wants to hide private parts from the end user on the outside of the APIs.\r\n\r\nThis allows for patterns like object managers being able to control certain aspects of the objects they manage (for example a renderer in a game engine that manages how objects in a scene render, and the renderable properties that the engine manager accesses, which are private to the end user) are composed from reactions to changes in the objects' public APIs by end users).\r\n\r\nAt the moment, the only way to allow objects to access properties of other objects is to make them public, but this does not allow for us to hide (at least in the type system) certain implementation details of a cross-class or cross-module whole system from the end user.\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* [ ] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n  - I'm not sure about this. This feature wouldn't change semantics of JavaScript, or add any JavaScript features, but would only add additional type capabilities to limit use of APIs in certain ways. In plain JS, before I ported a JavaScript project to TypeScript, I had an object manager that accessed properties prefixed with `__` to denote that the properties were not to be used by the end user. The engine accessed the properties for internal implementation of the system.\r\n","author":{"url":"https://github.com/trusktr","@type":"Person","name":"trusktr"},"datePublished":"2019-12-06T21:45:09Z","url":"https://github.com/microsoft/TypeScript/issues/35554"}

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:f224f56d-e5e0-f5de-7c36-4db02bb9dc8f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCB12:3ABEF2:70A5CB:964F8B:6B00AEA4
html-safe-nonce1fed8c04d897979377915023169aa0031d4d358991c2fd9defff87a0f3b491de
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjEyOjNBQkVGMjo3MEE1Q0I6OTY0RjhCOjZCMDBBRUE0IiwidmlzaXRvcl9pZCI6IjY4MzY0OTUzMTQ1MjY5NzM2MDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca8d062c4de3ce1a7e8a650582a54d9539f7081593cc42482878e5760039ba748
hovercard-subject-tagissue:534271865
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/35554/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3b6084e4e416cedc958d7da68b05ec4558da42c739d2eec1373ba77b49f00c29/microsoft/TypeScript/issues/35554
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3b6084e4e416cedc958d7da68b05ec4558da42c739d2eec1373ba77b49f00c29/microsoft/TypeScript/issues/35554
og:image:altSuggestion A way to allow certain other modules to access properties or methods of a class. Use Cases Sometimes, we want other modules (other code) to have access to certain properties or methods, ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametrusktr
hostnamegithub.com
expected-hostnamegithub.com
Nonec0dd5f5d6f515a591019ecd66df2c4eab3379c2d3b0777568a90d8c7ae10b79e
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
release729d8cda69b3d267995675dfbf89ff27ccf61bf6
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/35554#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F35554
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%2F35554
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/35554
Reloadhttps://github.com/microsoft/TypeScript/issues/35554
Reloadhttps://github.com/microsoft/TypeScript/issues/35554
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/35554
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35554
Add a visibility mechanism similar to friend or InternalsVisibleTohttps://github.com/microsoft/TypeScript/issues/35554#top
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/trusktr
Joe Pea (trusktr)https://github.com/trusktr
on Dec 6, 2019https://github.com/microsoft/TypeScript/issues/35554#issue-534271865
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Dec 6, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-562786542
#5228https://github.com/microsoft/TypeScript/issues/5228
https://github.com/trusktr
Joe Pea (trusktr)https://github.com/trusktr
on Dec 7, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-562826185
#5228 (comment)https://github.com/microsoft/TypeScript/issues/5228#issuecomment-562822307
https://github.com/lorenzodallavecchia
Lorenzo Dalla Vecchia (lorenzodallavecchia)https://github.com/lorenzodallavecchia
on Dec 7, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-562851312
InternalsVisibleTohttps://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.internalsvisibletoattribute?redirectedfrom=MSDN&view=netframework-4.8
@packagehttps://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#package
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Dec 7, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-562854247
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Dec 9, 2019https://github.com/microsoft/TypeScript/issues/35554#event-2867496158
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Dec 9, 2019https://github.com/microsoft/TypeScript/issues/35554#event-2867497552
https://github.com/trusktr
Joe Pea (trusktr)https://github.com/trusktr
on Dec 11, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-564398798
visibleinhttps://github.com/visiblein
https://github.com/lorenzodallavecchia
Lorenzo Dalla Vecchia (lorenzodallavecchia)https://github.com/lorenzodallavecchia
on Dec 11, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-564419636
https://github.com/trusktr
Joe Pea (trusktr)https://github.com/trusktr
on Dec 11, 2019https://github.com/microsoft/TypeScript/issues/35554#issuecomment-564774055
https://github.com/EKashpersky
Yehor Kashperskyi (EKashpersky)https://github.com/EKashpersky
on Oct 12, 2020https://github.com/microsoft/TypeScript/issues/35554#issuecomment-707389995
https://github.com/captainrdubb
Joel Rainear Wills (captainrdubb)https://github.com/captainrdubb
on Apr 26, 2021https://github.com/microsoft/TypeScript/issues/35554#issuecomment-826879177
https://github.com/branko-d
branko-dhttps://github.com/branko-d
on Nov 26, 2021https://github.com/microsoft/TypeScript/issues/35554#issuecomment-979737464
#41316 (comment)https://github.com/microsoft/TypeScript/issues/41316#issuecomment-979746254
https://github.com/TurboEncabulator9000
TurboEncabulator9000https://github.com/TurboEncabulator9000
on Nov 1, 2023https://github.com/microsoft/TypeScript/issues/35554#issuecomment-1788299395
https://github.com/azerum
azerumhttps://github.com/azerum
on Dec 30, 2023https://github.com/microsoft/TypeScript/issues/35554#issuecomment-1872626933
TurboEncabulator9000https://github.com/TurboEncabulator9000
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/35554
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/35554
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featurehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Awaiting%20More%20Feedback%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%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.