-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix redundant export {}
in declaration file
#58912
Conversation
@microsoft-github-policy-service agree |
export {}
in declaration file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not sufficient to fix the issue. I'm not sure @RyanCavanaugh remembered in the linked issue, but we emit a export {}
not just to ensure module-ness, but to actually make privately scoped names work at all - unless a declaration file has a export declaration (not an export modifier - an export declaration) all names are implicitly exported. If we stop emitting this marker, that behavior has to change, so privates remain private. Breaking that will be a breaking change, though! Declaration files like
type A = 1;
export interface B {}
allow importing A
today, so forbidding that is a break - arguably a good one, but it'll be a break with a declaration file behavior we've had since approximately the origin of declaration files.
And here I always assumed declaration files worked exactly like source files w.r.t. what’s exported - before today I would have confidently told anyone who asked that |
Declaration files have really, really weird export semantics. Been trying to augment ts-eslint to handle that in typescript-eslint/typescript-eslint#8611 but it's definitely a battle, so not surprised to see this be wrong. |
It hasn't really needed to be something we've needed to think about since our declaration emitter started emitting privates and |
This is weird. I am implementing the So I want to ask, when a third-party tool wants to implement |
Yes. If you're implementing isolated declarations, you should be using |
For future implementors of isolated declarations, you need port this "bug" as a feature 😁 We are already using the |
Yeah; if you do find anything weird, please do report it so we can at least make sure it isn't actually a bug. e.g. oxc-project/oxc#3798 is Not quite sure where to document |
Fixes #51338