Description
openedon Jan 19, 2019
Search Terms
isolated modules emit declaration
Suggestion
In the blog post introducing Babel 7, it's recommended to use --isolatedModules
in 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 isolatedModules
to our config, we get the following warning:
tsconfig.json:5:5 - error TS5053: Option 'declaration' cannot be specified with option 'isolatedModules'.
5 "declaration": true,
~~~~~~~~~~~~~
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 guarantees isolatedModules
adds 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 - isolatedModules
will 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:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.