Title: What do we call this command-line option? · Issue #2715 · microsoft/TypeScript · GitHub
Open Graph Title: What do we call this command-line option? · Issue #2715 · microsoft/TypeScript
X Title: What do we call this command-line option? · Issue #2715 · microsoft/TypeScript
Description: Consider two TypeScript files: _a.ts_ module M { export var t = 5; } _b.ts_ var t = 'foo'; module M { var s = t; // <-- what does this mean? } If we compile b.ts on its own, the t in var s = t refers to the outer var t, a string. The emi...
Open Graph Description: Consider two TypeScript files: _a.ts_ module M { export var t = 5; } _b.ts_ var t = 'foo'; module M { var s = t; // <-- what does this mean? } If we compile b.ts on its own, the t in var s = t refe...
X Description: Consider two TypeScript files: _a.ts_ module M { export var t = 5; } _b.ts_ var t = 'foo'; module M { var s = t; // <-- what does this mean? } If we compile b.ts on its own, the t in var...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/2715
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"What do we call this command-line option?","articleBody":"Consider two TypeScript files:\n**_a.ts**_\n\n``` ts\nmodule M {\n export var t = 5;\n}\n```\n\n**_b.ts**_\n\n``` ts\nvar t = 'foo';\nmodule M {\n var s = t; // \u003c-- what does this mean?\n}\n```\n\nIf we compile b.ts on its own, the `t` in `var s = t` refers to the outer var `t`, a `string`. The emit for this line is simply `var s = t;`.\n\nIf we compile b.ts _along with a.ts_, the `t` in `var s = t` refers to `M.t`, the exported variable of type `number`. The emit for this line is `var s = M.t`.\n\nThis behavior, and a few other language features (e.g. `const enum`), prevent TypeScript from being able to correctly operate on a single file without understanding the entire universe of files involved in the program. This has performance implications for features like compile-on-save, especially in larger projects, and blocks scenarios like on-the-fly compilation in module loaders.\n\nWe'd really prefer to be able to _emit_ a file without first understanding the entire program it's a part of. The language as-is prevents this. However, by slightly subsetting the language to disallow things that require whole-program binding/typechecking, we can re-enable those scenarios. People can \"opt in\" their project to this language subset as a trade-off.\n\nTentatively, we're calling the prongs of this fork \"whole program mode\" and \"single file mode\". Naming TBD.\n\nA key part of this is that you need to be able to compile e.g. a.ts and b.ts above in a mode that says \"This code will not work in single-file-mode\", e.g.:\n\n```\n > tsc --warnMeIfThisIsNotSafeInSingleFileMode a.ts b.ts\nTS1234 (b.ts line 2): Modules may not be re-opened in single-file mode\n```\n\nWe need some help naming these things, especially the commandline flag. The current list of ideas on the whiteboard, of which nobody likes anything, consists of the following :frowning:\n- `separateCompile`\n- `singleFileEmit`\n- `disableGlobalOptimizations`\n- `safeForTranspile`\n- `safeForSyntacticTranspilation`\n- `separate`\n- `isolated`\n- `safeTransform`\n- `singleFileScope`\n- `crossFileSafe`\n- `crossFileRestrictions`\n\nPlease help :bike: :house:!\n\nRef #2499\n","author":{"url":"https://github.com/RyanCavanaugh","@type":"Person","name":"RyanCavanaugh"},"datePublished":"2015-04-10T19:33:01Z","url":"https://github.com/microsoft/TypeScript/issues/2715"}
| 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:faf24058-ddd3-03d3-ecc2-a9f526738d41 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF88:4E3C:BCBC88:FB72E8:6B00F22A |
| html-safe-nonce | 448e4fa6e47d4738d6d314d2004f4110695f8867db2807b070eaefe72b151650 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjg4OjRFM0M6QkNCQzg4OkZCNzJFODo2QjAwRjIyQSIsInZpc2l0b3JfaWQiOiI3MDI0ODM2MjE4OTM2NDIyOTU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | cc7c56cb77de9c1f4d0ce850bde9f0897472edcf661de71639104ce189d9feb4 |
| hovercard-subject-tag | issue:67665721 |
| 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/2715/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6cb4d23f5b2baa336db68f41aa649853842d4fa868e36fa47690f6dd2854d17d/microsoft/TypeScript/issues/2715 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6cb4d23f5b2baa336db68f41aa649853842d4fa868e36fa47690f6dd2854d17d/microsoft/TypeScript/issues/2715 |
| og:image:alt | Consider two TypeScript files: _a.ts_ module M { export var t = 5; } _b.ts_ var t = 'foo'; module M { var s = t; // <-- what does this mean? } If we compile b.ts on its own, the t in var s = t refe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RyanCavanaugh |
| 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