Skip to content

Emit 'export as namespace ts' in our bundled d.ts output - #53570

Closed
Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:export-as-namespace
Closed

Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:export-as-namespace

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Mar 29, 2023 •

Copy link
Copy Markdown
Member

I was reading https://johnnyreilly.com/definitely-typed-the-movie and saw the export as namespace syntax, which triggered a memory that made me remember that we used to have this in our output pre-modules, but I did not preserve it.

Before, we had:

  • typescript.d.ts, which only had export = ts
  • tsserverlibrary.d.ts, which had both export = ts and export as namespace ts.
  • typescriptServices.d.ts, which just declared the ts namespace without exporting it.

Given we still let ts be loaded on the globals if not in CJS, this seems like it's correct to say that there's a global ts namespace when not imported.

Comment thread tests/baselines/reference/api/tsserverlibrary.d.ts
@fatcerberus

Copy link
Copy Markdown

Wait, typescript.d.ts and typescriptServices.d.ts were different despite that the corresponding .js files were identical?

@jakebailey

Copy link
Copy Markdown
Member Author

Yes, yes they were!

@jakebailey

Jake Bailey (jakebailey) commented Mar 29, 2023 •

Copy link
Copy Markdown
Member Author

Daniel Rosenwasser (@DanielRosenwasser) I stuck this in 5.0.3 as this feels like something we should backport for the patch release?

Not totally sure how to test that this doesn't negatively impact anyone but I'm pretty sure it does not.

@DanielRosenwasser

Copy link
Copy Markdown
Member

I'm confused, didn't we say these files shouldn't contain an export as namespace in chat?

@jakebailey

Jake Bailey (jakebailey) commented Mar 29, 2023 •

Copy link
Copy Markdown
Member Author

I think we started with "nobody's complaining, so why bother", but Andrew (and I, originally) seemed to think that if the output file would put itself into the globals when not loaded via an import that it should declare so.

@jakebailey
Jake Bailey (jakebailey) marked this pull request as draft March 30, 2023 21:02
@jakebailey

Copy link
Copy Markdown
Member Author

We're like 10 months post-module migration; given nobody has complained about this I'm just going to close this. If we ever want to change that, we can still revive this, but I really suspect anyone who wants us in a browser is just bundling anyhow.

@jakebailey
Jake Bailey (jakebailey) deleted the export-as-namespace branch January 29, 2024 19:40
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants