Plugin produces errors that tsc doesn't
See original GitHub issueFormerly I was using rollup for typescript compilation via babel and the normal typescript compiler to emit declarations (tsc --emitDeclarationsOnly
). Now I’d like to migrate to use your plugin. I have this configuration:
...
plugins: [
...
ts({
tsconfig: resolvedOptions => ({
emitDeclarationsOnly: true
})
})
]
However, with this setup I get some compilation errors from a library in node_modules. Both the tsc --emitDeclarationsOnly
and the babel compilation are working without any compile errors.
For debugging purposes I was adding a console.log(resolvedOptions)
and to my surprise it was invoked two times. The first time the options are looking OK but I have the feeling that it is not really compiling anything as it takes less then a second which is way faster then the normal tsc
(normally my compilation takes 5 seconds or so).
The second time in the options some values are changed (outDir
is set to “da39a3ee” and baseUrl
is set to “.”) and on this second run it produces the compile error.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hi again,
Yes, this plugin will generate fundamentally different declarations than
tsc
does, given that one of the key features of this plugin is declaration bundling. That is one of the primary reasons I’ve found that users generally chooserollup-plugin-ts
, given that it follows the folder structure of Rollup and even supports code splitting of the declaration files. Please read this section in the README for more details.I will close this issue for now, but if you run into any other problems, feel free to create a new issue.
Sorry for the late reply. We have solved our problem in the meantime with a different setup (using
execute('tsc --emitDeclarationsOnly')
with the “rollup-plugin-execute”) and it works for us.I’ve tried the
transpiler: "babel"
option but still got some weird compilation errors. I had to usetranspileOnly: true
to rid of the errors. However, the resulting d.ts files are different from whattsc --emitDeclarationsOnly
is producing. tsc does recreate the folder structure and puts each d.ts-file in the same sub-folder as it’s source-file while the plugin removes all folders and puts all files in directly in thedist/@types directory
.I’m not sure if I find the time to create a separate minimal repo. sorry.