Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow "export as namespace" in non-declaration files #9678

Closed
nippur72 opened this issue Jul 13, 2016 · 7 comments
Closed

allow "export as namespace" in non-declaration files #9678

nippur72 opened this issue Jul 13, 2016 · 7 comments
Labels
Suggestion An idea for TypeScript

Comments

@nippur72
Copy link

According to #7125, the new export as namespace

[...] is only legal as a top-level declaration a .d.ts file containing other top-level export declarations

Now this is a nuisance for library authors that are generating declarations via the --declaration flag, because everytime there's a recompile, .d.ts are rewritten and the export as namespace typed previously is gone.

What about if export as namespace could be written in the actual code and exported in the generated .d.ts file? E.g.:

myreact.ts:

export function createElement() { /* ... */ };
export as namespace React;

(generated) myreact.d.ts:

export declare function createElement() {};
export as namespace React;
@mhegazy mhegazy added the Suggestion An idea for TypeScript label Jul 13, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Jul 13, 2016

so what would the emitted code be?

@nippur72
Copy link
Author

the emitted code would be none: export as namespace would be ignored in .ts but written into .d.ts.

@mhegazy
Copy link
Contributor

mhegazy commented Jul 13, 2016

mmm.. that is not what i would expect from a declaration like that in a .ts file. for instance export = does emit code, and do not expect you to assign the output to module.exports yourself. so why would this be any different.

@nippur72
Copy link
Author

what about if the emitted code is a publishing into globals as per your suggestion in #8436 ?

@mhegazy
Copy link
Contributor

mhegazy commented Jul 13, 2016

yup. that is what i had in mind, though i forgot about that other comment :)

@mhegazy mhegazy added the In Discussion Not yet reached consensus label Jul 13, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Jul 13, 2016

#8436 seems to have more details. would you mind moving this suggestion to #8436.

@nippur72
Copy link
Author

closing as discussion merges with #8436

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants