Title: Avoiding pollution of environment's namespace · Issue #3338 · microsoft/TypeScript · GitHub
Open Graph Title: Avoiding pollution of environment's namespace · Issue #3338 · microsoft/TypeScript
X Title: Avoiding pollution of environment's namespace · Issue #3338 · microsoft/TypeScript
Description: This is somewhat related to #2923, but I'm deliberately opening a separate item because the discussion there has abruptly stopped and more importantly I don't think we're on the right track for the issue at hand. Let's restate the issue ...
Open Graph Description: This is somewhat related to #2923, but I'm deliberately opening a separate item because the discussion there has abruptly stopped and more importantly I don't think we're on the right track for the...
X Description: This is somewhat related to #2923, but I'm deliberately opening a separate item because the discussion there has abruptly stopped and more importantly I don't think we're on the right t...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/3338
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Avoiding pollution of environment's namespace","articleBody":"This is somewhat related to #2923, but I'm deliberately opening a separate item because the discussion there has abruptly stopped and more importantly I don't think we're on the right track for the issue at hand.\n\nLet's restate the issue differently: imagine a simple TS project which uses **no** modules or namespaces, because it's really annoying to export/import almost every class in the project. It's not a library other people will use, it's just something I use for my own site(s). I use the feature of the TS compiler to produce a single JS file and reference it from my HTML5 page(s).\n\nHowever, I don't like the fact that my 'classes' are polluting the global namespace of the browser environment (had I used the project for node/server side development, the result would be similary unpleasant).\n\nEvery discussion around this issue leads (inevitably?) to `modules` or `namespaces`, but more I think about this more it seems to me we're not on a right track.\n\nWhile `modules` and/or `namespaces` do allow for quite fine-grained level of control regarding visibility of 'classes', for the simple case I simply want _everything visible_, but I _don't_ want it in a global namespace of the environment, I want to separate it so I don't produce clashes with other scripts running in the same environement/page. IOW, inside my project everything is 'public', outside too (I'd rather make everything visible than export/import all the time) but not in a global namespace of the environment.\n\nWould it be at all reasonable to expect the TS compiler to support this scenario through a flag or option in `tsconfig.json` the final result being identical to regular compilation but wrapping everything in a IIFE while preserving source maps info? It's understood that this option would effectively 'deactivate' any and all notions of `modules`/`namespaces` (it would be invalid to use the two at the same time).\n\nOr should I assume this will never be implemented and look into wrapping the final result myself through a custom build step (which should be possible but is slightly irritating to do when one uses sourcemaps as they will be invalidated by wrapping)?\n","author":{"url":"https://github.com/ddotlic","@type":"Person","name":"ddotlic"},"datePublished":"2015-06-02T09:08:23Z","url":"https://github.com/microsoft/TypeScript/issues/3338"}
| 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:04e10c1b-2e24-bb43-91bd-295cf1a5f43a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E286:1C94F:C6D20:FF42E:6B00F721 |
| html-safe-nonce | 26f778c5aff7505b4150c273098479919577e1aa9d2e2349fafbc7dc008d11fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjg2OjFDOTRGOkM2RDIwOkZGNDJFOjZCMDBGNzIxIiwidmlzaXRvcl9pZCI6IjMwOTE1MDA3MzI1NTg0MDc0NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e8daa28286b52c3d7f2f764a6cd7e238262382c9a68598f529e17e4cac84546d |
| hovercard-subject-tag | issue:83928152 |
| 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/3338/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c32410ed1d386501aebf11239bf4e370fcd688e540ae9a087506171f8c23c805/microsoft/TypeScript/issues/3338 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c32410ed1d386501aebf11239bf4e370fcd688e540ae9a087506171f8c23c805/microsoft/TypeScript/issues/3338 |
| og:image:alt | This is somewhat related to #2923, but I'm deliberately opening a separate item because the discussion there has abruptly stopped and more importantly I don't think we're on the right track for the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ddotlic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width