Title: export access modifiers · Issue #41316 · microsoft/TypeScript · GitHub
Open Graph Title: export access modifiers · Issue #41316 · microsoft/TypeScript
X Title: export access modifiers · Issue #41316 · microsoft/TypeScript
Description: Search Terms export access modifiers public protected private Related: #321 Suggestion Allow adding public, protected and private access modifiers to export statements. This would limit where the data can be imported from. Access Modifie...
Open Graph Description: Search Terms export access modifiers public protected private Related: #321 Suggestion Allow adding public, protected and private access modifiers to export statements. This would limit where the d...
X Description: Search Terms export access modifiers public protected private Related: #321 Suggestion Allow adding public, protected and private access modifiers to export statements. This would limit where the d...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/41316
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"export access modifiers","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ, especially the \"Common Feature Requests\" section: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->\r\nexport access modifiers public protected private\r\n\r\nRelated: #321\r\n\r\n## Suggestion\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed -->\r\nAllow adding `public`, `protected` and `private` access modifiers to export statements. This would limit where the data can be imported from.\r\n\r\n### Access Modifiers\r\n\r\n#### `private`\r\n\r\nOther file in the same directory scope have access to the export.\r\n\r\n#### `protected`\r\n\r\nOther file in the same directory scope or a nested scope have access to the export.\r\n\r\n#### `public` (default)\r\n\r\nCurrent behavior - Can be access from anywhere.\r\n\r\n## Use Cases\r\n\r\nMost useful for large projects - allows modules to limit where things they expose are used.\r\n\r\n## Examples\r\n\r\nGiven the following director structure:\r\n\r\n```txt\r\n.\r\n├── module\r\n│ ├── submodule\r\n│ │ └── index.ts\r\n│ ├── file.ts\r\n│ └── index.ts\r\n└── index.ts\r\n```\r\n\r\n```ts\r\n// module/file.ts\r\npublic export const foo = \"hello\";\r\nprotected export const bar = \"world\";\r\nprivate export const baz = \"!!!\";\r\n```\r\n\r\n```ts\r\n// module/submodule/index.ts\r\nimport { foo, bar, baz } from '../file';\r\n // ^^^ Cannot access baz as is private.\r\n```\r\n\r\n```ts\r\n// module/index.ts\r\nimport { foo, bar, baz } from './file'; // All Ok.\r\n```\r\n\r\n```ts\r\n// index.ts\r\nimport { foo, bar, baz } from './module/file';\r\n // ^^^ Cannot access bar as is protected.\r\n // ^^^ Cannot access baz as is private.\r\n```\r\n\r\nNote: If using `import * as X from ...`, `X`'s type simply wouldn't include things it doesn't have access to.\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* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n","author":{"url":"https://github.com/RebeccaStevens","@type":"Person","name":"RebeccaStevens"},"datePublished":"2020-10-29T01:27:39Z","url":"https://github.com/microsoft/TypeScript/issues/41316"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7e89dff4-2566-d879-5968-fee5ae7f7e5f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84C4:3C21B:206CF2:2AFA50:6B00BF12 |
| html-safe-nonce | 126c97bc5733ec7b9dc96eec04b2d63f2db0e9465826609c86a6383cf0bdfb9e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEM0OjNDMjFCOjIwNkNGMjoyQUZBNTA6NkIwMEJGMTIiLCJ2aXNpdG9yX2lkIjoiNzUxNDI4NzM1NDc5ODk4MDg4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ab649648ebbe2d2d22a48e1cc85c4777c7df9d2865b34ea6f00b4ff27dce6e9 |
| hovercard-subject-tag | issue:731921865 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/41316/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9a0012210a2850ba825cf91b8adbb8c98ae8e53ade420a8aaab74a272ff80b44/microsoft/TypeScript/issues/41316 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9a0012210a2850ba825cf91b8adbb8c98ae8e53ade420a8aaab74a272ff80b44/microsoft/TypeScript/issues/41316 |
| og:image:alt | Search Terms export access modifiers public protected private Related: #321 Suggestion Allow adding public, protected and private access modifiers to export statements. This would limit where the d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RebeccaStevens |
| hostname | github.com |
| expected-hostname | github.com |
| None | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width