Is it possible to import declaration files with this plugin?
See original GitHub issueI have a dependency with a single .ts
source file that imports declarations from many .d.ts
declaration files. When Rollup hits a declaration file, I get a PARSE_ERROR
telling me that Rollup is trying to parse the TypeScript declaration file as an ES module. I tracked that down to the exclude
setting for this plugin which skips .d.ts
files by default. After setting exclude: []
, this plugin parses the file, but whatever ES module it returns to Rollup is missing the declarations inside, because I get a MISSING_EXPORT
error. Is there a way to see what ES module this plugin is returning for a given TS declaration file? Is there a way to get it to include all the exports in a declaration file?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
A quick introduction to “Type Declaration” files and adding ...
The standard library (global type declaration) files are imported implicitly by the TypeScript compiler by looking at the lib compiler-option ( ...
Read more >How to import js module when Typescript declaration file is ...
Create an empty folder and then run npm -y init · Run the following command: · Add "build": "rollup --config" to your package....
Read more >Module: Plugin - TypeScript: Documentation
Some plugins add or modify top-level exports on existing modules. While this is legal in CommonJS and other loaders, ES6 modules are considered...
Read more >TypeScript | IntelliJ IDEA Documentation - JetBrains
Add import statements on code completion · In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | General | Auto Import. The...
Read more >rollup-plugin-ts - npm
Absolutely, even with Declaration files. Things will work seamlessly. Why wouldn't you use just TypeScript? The TypeScript compiler, while ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For rollup, the problem is that d.ts don’t contain any code that translate to java script – translated d.ts file is an empty js file.
Normally you are not supposed to import d.ts files directly, but let typescript find them itself (by setting
types
parameter in package, etc).Going to close this out as I believe this has been answered well and in entirety – declarations are indeed not supposed to be imported and indeed would not produce valid ES modules. That is TS behavior and not specific to this plugin.
OP also suggested themselves that the issue was not with this plugin and has not responded to further comments.
Note that triple-slash directives may behave differently, which may be what OP intended to do instead?