-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow emitDeclaration and isolatedModules together #29490
Copy link
Copy link
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueFix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueFix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Search Terms
isolated modules emit declaration
Suggestion
In the blog post introducing Babel 7, it's recommended to use
--isolatedModulesin the "Caveats" section (https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/).We use Babel to transpile our TS to better work with other tools in the ecosystem (such as Emotion or Jest), but we'd also still like to generate declaration files so consumers of our libraries can enjoy the type information.
However, when trying to follow the advice of adding
isolatedModulesto our config, we get the following warning:Use Cases
As mentioned, I'd like to create declaration files for libraries who are transpiled using
babel. I'd also like to make sure that whatever guaranteesisolatedModulesadds to allowed syntax are present, outside of the type information.Babel itself will complain if we use e.g.
const enum, but that only happens at compile time -isolatedModuleswill also show a warning in the IDE while writing the code.Examples
Same as we currently get with
{"declaration": true, "emitDeclarationOnly": true}, but with added{"isolatedModules": true}.Checklist
My suggestion meets these guidelines: