René's URL Explorer Experiment


Title: Add compiler option to allow module types to be checked in non module output files · Issue #41567 · microsoft/TypeScript · GitHub

Open Graph Title: Add compiler option to allow module types to be checked in non module output files · Issue #41567 · microsoft/TypeScript

X Title: Add compiler option to allow module types to be checked in non module output files · Issue #41567 · microsoft/TypeScript

Description: Search Terms: import type, export {} Suggestion In #41513 and #41562 projects are broken by a design change to always include export {}; in the JS output if import or import type is in the TS source, regardless of whether it is in the JS...

Open Graph Description: Search Terms: import type, export {} Suggestion In #41513 and #41562 projects are broken by a design change to always include export {}; in the JS output if import or import type is in the TS sourc...

X Description: Search Terms: import type, export {} Suggestion In #41513 and #41562 projects are broken by a design change to always include export {}; in the JS output if import or import type is in the TS sourc...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add compiler option to allow module types to be checked in non module output files","articleBody":"**Search Terms:** `import type`, `export {}`\r\n\r\n## Suggestion\r\n\r\nIn #41513 and #41562  projects are broken by a design change to always include `export {};` in the JS output if `import` or `import type` is in the TS source, regardless of whether it is in the JS output. This is a breaking change for a lot of developers and painful to fix (and by fix I mean practically get the output of our TS project to run in browsers, not necessarily adhere to ECMA spec compliance and best possible practice).\r\n\r\nHowever, `export {};` considered desirable:\r\n\r\n> You're free to suggest a new compiler option but this is the intentional behavior.\r\n> _Originally posted by @RyanCavanaugh in https://github.com/microsoft/TypeScript/issues/41513#issuecomment-727057724_\r\n\r\nPlease could we have a new compiler option to not force all files that in any way use ES modules to always have to include `export {};` in the JS output. \r\n\r\nI'm not sure of the best way for this to be applied, but the goal would be\r\n- Type checking compatible with an ESM project.\r\n- Output compatible with the current state of module support in browsers.\r\n\r\nThis could be:\r\n- A compiler option that causes `import type` to not implicitly convert output to a module, (my preference because it still avoids any output JS having `import` without `export`, which caused #38696) or \r\n- A compiler option to not add `export {};` to _all_ modules, or \r\n- A `//@directive` we add to a file to express our intent to not output a module, or\r\n- A new `reference type ...` TS-only syntax to signal that we want to use the definition but not output a module \r\n\r\nWhatever is easiest to code and causes least friction/confusion for the community.\r\n\r\n## Use Cases\r\n\r\nI have a large TS project that uses numerous web workers, a service worker and web components that load side effects.\r\n\r\nIn the first two cases including `export {};` breaks the resulting JS, as these workers are not modules and are not intended to produce module loaded JS output.\r\n\r\nIn the case of side effect web components no `export` is expected (they use `customElements.define`) so it's just wasted bytes, but it doesn't break anything. Across a project with a lot of components the many `export {};` that will never be referenced by anything adds up.\r\n\r\nIn addition during migration between different reference types it may be extremely beneficial to not strictly enforce adherence to one type or the other, at least while not in production. Any modules = all must be modules effectively makes this migration harder, even if it is a sound best practice.\r\n\r\n## Examples\r\n\r\nI have a model `MyModel.d.ts`. \r\n\r\nIn `worker.ts` I want TS to check my code against this model:\r\n\r\n```ts\r\nimport type MyModel from './MyModel';\r\nconst test: MyModel = {};\r\ntest.propertyInModel = 1; // works and has intellisense\r\n// test.propertyNotInModel = 1; throws compile error!\r\n```\r\n\r\nI want to use the JS output this with a worker in another file:\r\n\r\n```ts\r\nconst worker = new Worker('path/worker.js');\r\n```\r\n\r\nThis worked in 3.8, but fails in 4.0 due to #41562\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 (it would fix a lot of projects broken by 4.0)\r\n* [x] This wouldn't change the runtime behaviour of existing JavaScript code (it would be opt-in)\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.) (we're removing additional content that wasn't in 3.8)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals). (particularly 4, 7 and 11)\r\n","author":{"url":"https://github.com/KeithHenry","@type":"Person","name":"KeithHenry"},"datePublished":"2020-11-17T17:39:19Z","url":"https://github.com/microsoft/TypeScript/issues/41567"}

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:8dbf1626-499e-e036-694d-1f58fd91de2b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB9EE:2D2F2F:26F5CDD:31BBEEA:6B018735
html-safe-nonce72afd56329de5ec7fee3d22ec16c614ac823a4f5c506bec628ba62fde4046ca8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUVFOjJEMkYyRjoyNkY1Q0REOjMxQkJFRUE6NkIwMTg3MzUiLCJ2aXNpdG9yX2lkIjoiMTI2MTcyMzQzMDQyMDU4MDE1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaccf90ab56a6d8e1f6d1643dcb7ca85fe6faa38bc6544b295dfb06228797ef8968
hovercard-subject-tagissue:744944457
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/41567/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bb413c7278dd8ee575f1299ba6b6d6647e0992f7981e54004a2615d01db7b5dc/microsoft/TypeScript/issues/41567
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bb413c7278dd8ee575f1299ba6b6d6647e0992f7981e54004a2615d01db7b5dc/microsoft/TypeScript/issues/41567
og:image:altSearch Terms: import type, export {} Suggestion In #41513 and #41562 projects are broken by a design change to always include export {}; in the JS output if import or import type is in the TS sourc...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKeithHenry
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/41567#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F41567
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%2F41567
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/41567
Reloadhttps://github.com/microsoft/TypeScript/issues/41567
Reloadhttps://github.com/microsoft/TypeScript/issues/41567
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)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/41567
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/41567
Add compiler option to allow module types to be checked in non module output fileshttps://github.com/microsoft/TypeScript/issues/41567#top
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/KeithHenry
Keith Henry (KeithHenry)https://github.com/KeithHenry
on Nov 17, 2020https://github.com/microsoft/TypeScript/issues/41567#issue-744944457
#41513https://github.com/microsoft/TypeScript/issues/41513
#41562https://github.com/microsoft/TypeScript/issues/41562
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
#41513 (comment)https://github.com/microsoft/TypeScript/issues/41513#issuecomment-727057724
Consider emitting export {} in all ambiguous module output #38696https://github.com/microsoft/TypeScript/issues/38696
#41562https://github.com/microsoft/TypeScript/issues/41562
TypeScript's Design Goalshttps://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
Nexthttps://github.com/microsoft/TypeScript/issues/41567?timeline_page=1
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Nov 17, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-729236213
#38712https://github.com/microsoft/TypeScript/pull/38712
https://github.com/KeithHenry
Keith Henry (KeithHenry)https://github.com/KeithHenry
on Nov 18, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-729600259
Andrew Branch (@andrewbranch)https://github.com/andrewbranch
#41562https://github.com/microsoft/TypeScript/issues/41562
bundlers are often bad athttps://bundlers.tooling.report/code-splitting/multi-entry/
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Nov 18, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-729837317
https://github.com/KeithHenry
Keith Henry (KeithHenry)https://github.com/KeithHenry
on Nov 19, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-730213444
Andrew Branch (@andrewbranch)https://github.com/andrewbranch
Comlinkhttps://github.com/GoogleChromeLabs/comlink
https://github.com/AlCalzone
AlCalzonehttps://github.com/AlCalzone
on Nov 19, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-730219138
#13135https://github.com/microsoft/TypeScript/issues/13135
https://github.com/KeithHenry
Keith Henry (KeithHenry)https://github.com/KeithHenry
on Nov 19, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-730421378
AlCalzonehttps://github.com/AlCalzone
#13135https://github.com/microsoft/TypeScript/issues/13135
#41562https://github.com/microsoft/TypeScript/issues/41562
#13135https://github.com/microsoft/TypeScript/issues/13135
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Nov 19, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-730555669
Keith Henry (@KeithHenry)https://github.com/KeithHenry
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Nov 20, 2020https://github.com/microsoft/TypeScript/issues/41567#event-4022293612
https://github.com/jon49
Jon Nyman (jon49)https://github.com/jon49
on Nov 21, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-731469860
https://github.com/KeithHenry
Keith Henry (KeithHenry)https://github.com/KeithHenry
on Nov 23, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-732466597
Andrew Branch (@andrewbranch)https://github.com/andrewbranch
https://github.com/blixt
Blixt (blixt)https://github.com/blixt
on Dec 30, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-752698958
#14877https://github.com/microsoft/TypeScript/issues/14877
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Dec 30, 2020https://github.com/microsoft/TypeScript/issues/41567#issuecomment-752712640
Blixt (@blixt)https://github.com/blixt
https://github.com/jon49
Jon Nyman (jon49)https://github.com/jon49
on Nov 24, 2021https://github.com/microsoft/TypeScript/issues/41567#issuecomment-977483140
16577https://github.com/microsoft/TypeScript/issues/16577
And anotherhttps://github.com/microsoft/TypeScript/issues/15479#issuecomment-543329547
https://github.com/kbalint
Balint Kardos (kbalint)https://github.com/kbalint
on Jan 5, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1005729783
npmhttps://www.npmjs.com/package/@microsoft/signalr
this tutorialhttps://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Jun 3, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1146434073
#47724https://github.com/microsoft/TypeScript/issues/47724
https://github.com/haydentech
Bill Hayden (haydentech)https://github.com/haydentech
on Jun 24, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1165819479
Bill Hayden (@haydentech)https://github.com/haydentech
https://github.com/andrewbranch
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Jun 24, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1165850605
https://github.com/jon49
Jon Nyman (jon49)https://github.com/jon49
on Jun 25, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1166233801
https://github.com/ValeTheVioletMote
Vale the Violet Mote (ValeTheVioletMote)https://github.com/ValeTheVioletMote
on Aug 2, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1202567591
https://github.com/SachinShekhar
Sachin Shekhar (SachinShekhar)https://github.com/SachinShekhar
on Aug 10, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1210410774
https://github.com/KeithHenry
Keith Henry (KeithHenry)https://github.com/KeithHenry
on Aug 17, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1217679835
https://github.com/Vardner
Yehor (Vardner)https://github.com/Vardner
on Oct 10, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1273194121
https://github.com/ValeTheVioletMote
Vale the Violet Mote (ValeTheVioletMote)https://github.com/ValeTheVioletMote
on Oct 10, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1273274825
https://github.com/jon49
Jon Nyman (jon49)https://github.com/jon49
on Oct 11, 2022https://github.com/microsoft/TypeScript/issues/41567#issuecomment-1275227653
pospi (pospi)https://github.com/pospi
on Apr 25, 2023https://github.com/microsoft/TypeScript/issues/41567#event-9088711776
change test commands & config to use tsx/ESBuild packages for compila…https://github.com/neighbour-hoods/sensemaker-lite/commit/7a7d658d4dc7b627c96eb59440e88bbaa4a00ac6
7a7d658https://github.com/neighbour-hoods/sensemaker-lite/commit/7a7d658d4dc7b627c96eb59440e88bbaa4a00ac6
pospi (pospi)https://github.com/pospi
on May 29, 2023https://github.com/microsoft/TypeScript/issues/41567#event-9366349690
change test commands & config to use tsx/ESBuild packages for compila…https://github.com/neighbour-hoods/sensemaker-lite/commit/b5fd021583cb56d1a1a7248ed182d50c3b38018e
b5fd021https://github.com/neighbour-hoods/sensemaker-lite/commit/b5fd021583cb56d1a1a7248ed182d50c3b38018e
Squashed commit of the following:https://github.com/neighbour-hoods/sensemaker-lite/commit/8419209da396fec26d381f0f98fbda0167463548
8419209https://github.com/neighbour-hoods/sensemaker-lite/commit/8419209da396fec26d381f0f98fbda0167463548
Squashed commit of the following:https://github.com/neighbour-hoods/sensemaker-lite/commit/ccb72965cff306854dbb9e4df3486c2ef3850fff
ccb7296https://github.com/neighbour-hoods/sensemaker-lite/commit/ccb72965cff306854dbb9e4df3486c2ef3850fff
pospi (pospi)https://github.com/pospi
on Nov 14, 2023https://github.com/microsoft/TypeScript/issues/41567#event-10961287492
change test commands & config to use tsx/ESBuild packages for compila…https://github.com/neighbour-hoods/sensemaker-lite/commit/c3e8fe53cb629fd1e2e1d39ff1b660cc5be0d7b8
c3e8fe5https://github.com/neighbour-hoods/sensemaker-lite/commit/c3e8fe53cb629fd1e2e1d39ff1b660cc5be0d7b8
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/41567
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/41567
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%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.