Repository navigation
Design Meeting Notes, 5/21/2020 #38713
Copy link
Copy link
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
Always Emit export {}
- What does "always" mean?
- If there were import/export statements in the file, there must at least be one import or export in the output.
- We already have this rule in declaration files.
- We just don't do it in module output.
- We probably do.
- This is valuable for tools like Webpack/TypeScript, but there's a class of users who won't want this.
- They will have a point.
- Conclusion
- Add the
export {}. - Do we need a patch release?
- Sounds like no.
- Preserve module marker in es2015+ module emit for tool compatibility #38712
- Add the
Optimization hints on classes
In 3.9 we started emitting an IIFE around classes with statics when targeting ES2015.
class C {
static x = someExpression();
}Becomes
let C = /** @class */ (() => {
class C {
}
C.x = someExpression();
});Closure can't understand this output.
- Why are we emitting the noise anywhere?
- Shouldn't classes be used? Sounds like it should've been a dead-code elimination problem.
- Bundlers not always good at tree-shaking.
- Want to give the option, but maybe the default should be nice output.
- Conclusion: ask more about the current issues, understand the problem better.
Allow modules to implement interfaces
- What about contextual typing and inference on the members?
- We already have that on values in general, don't co-mingle that.
- Operator to ensure an expression is contextually typed by, and satisfies, some type #7481
- What about being able to validate that types are present?
- Now you need to have meta-typed module system.
- Most people seem to just want to validate the types.
- What are the wins?
- React Native platform-specific modules.
- Config files
- Plugin Systems
- Mocking in Tests
- Maybe the syntax might differ depending on module type.
- Could imagine there's just a design-time check for type compatibility.
- Assert a value or type conforms to some other type.
- Problems
- The syntax space isn't fleshed out
- There's a lot of adjacent proposals
- There's no way to make this check things other than modules.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Activity
IgorMinar commentedon May 22, 2020
Daniel Rosenwasser (@DanielRosenwasser) I'm happy to talk to any of you about the class emit shape and #32011 - I think the wrapping is the right behavior at the moment. See #38374 (comment)
jon49 commentedon Nov 12, 2020
So, for those of us that don't want or need this behavior. What is the work around? This should be done explicitly by the user if they want to export
export {}. This breaks my code for service workers when I'm importing only types.mohsen1 commentedon Dec 8, 2021
RE: Allow modules to implement interfaces
export implementsseems like the most natural syntax to me. Compared tomodule implementsat least.modulehas a few meanings in TypeScript world.One of the biggest wins is Next.js and other similar frameworks that expect a file to export specifically named functions for various things.