René's URL Explorer Experiment


Title: Proposal: Bundling TS module type definitions · Issue #4433 · microsoft/TypeScript · GitHub

Open Graph Title: Proposal: Bundling TS module type definitions · Issue #4433 · microsoft/TypeScript

X Title: Proposal: Bundling TS module type definitions · Issue #4433 · microsoft/TypeScript

Description: Relates to #3159, #4068, #2568, this branch, and this tool. Goals Bundle declarations for TS projects to allow a library to be consumed with a single TS file, despite being many modules internally. Because of complicated internal module ...

Open Graph Description: Relates to #3159, #4068, #2568, this branch, and this tool. Goals Bundle declarations for TS projects to allow a library to be consumed with a single TS file, despite being many modules internally....

X Description: Relates to #3159, #4068, #2568, this branch, and this tool. Goals Bundle declarations for TS projects to allow a library to be consumed with a single TS file, despite being many modules internally....

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Bundling TS module type definitions","articleBody":"Relates to #3159, #4068, #2568, [this branch](https://github.com/Microsoft/TypeScript/compare/declarations...declarations-moduleOut), [and this tool](https://github.com/SitePen/dts-generator).\n# Goals\n- Bundle _declarations_ for TS projects to allow a library to be consumed with a single TS file, despite being many modules internally. Because of complicated internal module dependencies which would rather not be exposed to the consumer, this should flatten the exported module types as best as it can. (Ideally, completely.)\n# Proposal\n\nWhen all of `--module`, `--out`, and `--declarations` are specified, the TS compiler should emit a single amalgamated `.d.ts` (alongside its single output js file). This `.d.ts` should be flattened compared to a concatenated `.d.ts` file. It should report collisions caused by scoping issues and import aliasing when flattening declarations into a single `declare module`. It should respect access modifiers when generating the DTS (only exporting things explicitly exported and types marked as public). \n\nFor example, given the following set of sources:\n`tsconfig.json`:\n\n``` json\n{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"declarations\": true,\n    \"out\": \"mylib.js\"\n  }\n}\n```\n\n`a.ts`:\n\n``` ts\nexport * from './b';\nexport * from './c';\n```\n\n`b.ts`:\n\n``` ts\nexport interface Foo {}\n\nexport class Bar {\n    constructor() {\n        console.log('');\n    }\n\n    do(): Foo { throw new Error('Not implemented.'); }\n}\n```\n\n`c.ts`:\n\n``` ts\nexport class Baz {}\n```\n\nshould create the `.d.ts`:\n`mylib.d.ts`:\n\n``` ts\ndeclare module \"mylib\" {\n  export interface Foo {}\n\n  export class Bar {\n    constructor()\n    do(): Foo\n  }\n\n  export class Baz {}\n}\n```\n\nrather than:\n`mylib.d.ts`:\n\n``` ts\ndeclare module \"mylib/a\" {\n  export * from \"mylib/b\";\n  export * from \"mylib/c\";\n}\ndeclare module \"mylib/b\" {\n  export interface Foo {}\n\n  export class Bar {\n    constructor()\n    do(): Foo\n  }\n}\ndeclare module \"mylib/c\" {\n  export class Baz {}\n}\ndeclare module \"mylib\" {\n  export * from \"mylib/a\";\n}\n```\n\nand should report a semantic error when the following is done:\n`a.ts`:\n\n``` ts\nexport * from './b';\nexport {Bar as Foo} from './b';\nexport * from './c';\n```\n\nas there will be multiple members named `Foo` (an interface and a class), since `b.ts` has exported interface `Foo`.\n\nWe should also have a semantic error when the following is changed from the original:\nIf we change `c.ts`:\n\n``` ts\nexport class Baz {}\nexport interface Foo {}\n```\n\nit should be an error in `a.ts` (since it's blanket exporting `b` and `c`), and the error should suggest to alias either `c.ts`'s `Foo` or `b.ts`'s `Foo` (or both) when reexporting them in `a`.\n\nInternally, when flattening this aliasing becomes important - we need to track usages of the two original `Foo`'s across the generated `.d.ts` and rename it to the alias created when it is reexported.\n\nUnfortunately, to maintain ES6 compatability, while we can warn about this behavior with classes (since it's possible that a developer is unaware they're overriding a prior export), we still need to support it (or do we? The spec leads me to believe that attempting to export multiple members with the same name - even via `export *` - is an early syntax error). So it would be nice to have a compiler flag to mark the same kind of thing with classes (or namespaces) as an error, but also do the following by default:\n\nWe can do automatic name collision resolution, but that can result in unpredictable (or convention-based) public member names... but it must be done, I suppose. We could ignore reexported types since it's appropriate to do so in ES6 (following `export *` declarations can override previously defined members? maybe? system works this way at present - but that may just be system relying on transpiler implementers to maintain ES6 semantics), then we would need to create \"shadowed\" types at the appropriate level in the `.d.ts` - types whose original public access are overridden by later exports but whose types are still required to describe public function argument or return types. Naming these \"shadowed\" types could be difficult, but given that they only exist for type information and not for access information, a common (re)naming convention could be a desirable solution. Something akin to `\u003ctypename\u003e_n` when `n` is the shadowed type number for that type, and renaming the shadowed type name to something else (`\u003ctypename\u003e__n` and so on so long as the name still exists) if that collides with another exported type. Classes used in this way are rewritten to interfaces in the `.d.ts`, since a constructor function likely isn't accessible for a shadowed class (at least not at its generated exported type name).\n\nAny feedback? There's a few alternatives to what I've suggested here, which is possibly the most conservative approach in terms of ability to error early but supporting ES6 semantics best. It's possible to silently ignore `interface` name collisions and rename those automatically as well, but since they're TS constructs and not ES6, I think it's okay to force more discipline in their usage.\n\nSomething I've been considering is also rewriting `namespace`s as `interface`s in the generated `.d.ts` in this way to further flatten/unify the types, but this... might? not strictly be needed. I haven't come up with a strong case for it.\n","author":{"url":"https://github.com/weswigham","@type":"Person","name":"weswigham"},"datePublished":"2015-08-25T00:03:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":84},"url":"https://github.com/4433/TypeScript/issues/4433"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d10a76a3-1e81-61cc-f8db-3369a31bc270
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC2A6:149595:439971:601976:6A637BED
html-safe-noncee6ad565f942e0f6d95715a7128fd9cc4723efe0072e2b280100464d474971b9f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkE2OjE0OTU5NTo0Mzk5NzE6NjAxOTc2OjZBNjM3QkVEIiwidmlzaXRvcl9pZCI6IjY3NDM1NDc3MDgyMjA2MDMzNzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac3770ffb02e5fef6d8189a6624f4a9757d4a3a14ae111bf624cfcbe03af23e6d0
hovercard-subject-tagissue:102917356
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/4433/issue_layout
twitter:imagehttps://opengraph.githubassets.com/dc97e134589bc7feb77a9a964a684bfef84f93fbb84ba4faf486ebd94ee5dc4b/microsoft/TypeScript/issues/4433
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/dc97e134589bc7feb77a9a964a684bfef84f93fbb84ba4faf486ebd94ee5dc4b/microsoft/TypeScript/issues/4433
og:image:altRelates to #3159, #4068, #2568, this branch, and this tool. Goals Bundle declarations for TS projects to allow a library to be consumed with a single TS file, despite being many modules internally....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameweswigham
hostnamegithub.com
expected-hostnamegithub.com
None4c1de337de00c7969335f8866af41463301071379a3a15fba12e9b85aa6378d6
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
releasea4df32552e4c631011bdcd4c81cc3d7408664a8b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/4433#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F4433
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F4433
Sign up https://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/4433
Reloadhttps://github.com/microsoft/TypeScript/issues/4433
Reloadhttps://github.com/microsoft/TypeScript/issues/4433
Please reload this pagehttps://github.com/microsoft/TypeScript/issues/4433
microsoft https://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Notifications https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Fork 13.6k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Star 110k https://github.com/login?return_to=%2Fmicrosoft%2FTypeScript
Code https://github.com/microsoft/TypeScript
Issues 5k+ https://github.com/microsoft/TypeScript/issues
Pull requests 21 https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality 0 https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Code https://github.com/microsoft/TypeScript
Issues https://github.com/microsoft/TypeScript/issues
Pull requests https://github.com/microsoft/TypeScript/pulls
Actions https://github.com/microsoft/TypeScript/actions
Projects https://github.com/microsoft/TypeScript/projects
Models https://github.com/microsoft/TypeScript/models
Wiki https://github.com/microsoft/TypeScript/wiki
Security and quality https://github.com/microsoft/TypeScript/security
Insights https://github.com/microsoft/TypeScript/pulse
Proposal: Bundling TS module type definitionshttps://github.com/microsoft/TypeScript/issues/4433#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/weswigham
weswighamhttps://github.com/weswigham
on Aug 25, 2015https://github.com/microsoft/TypeScript/issues/4433#issue-102917356
#3159https://github.com/microsoft/TypeScript/pull/3159
#4068https://github.com/microsoft/TypeScript/pull/4068
#2568https://github.com/microsoft/TypeScript/issues/2568
this branchhttps://github.com/Microsoft/TypeScript/compare/declarations...declarations-moduleOut
and this toolhttps://github.com/SitePen/dts-generator
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.