Closed vegidio closed 3 years ago
This seems to be happening because my
d.ts
entrypointdist/types/index.d.ts
is blank
I think thats because https://github.com/vegidio-js/template-typescript/blob/master/src/index.ts has no export
declarations in it. Typescript will do its own dead code elimination. And obviously if your index file is empty, this plugin won’t find anything.
Damn, such a silly mistake of mine 🙈 Sorry for wasting your time on this.
Typescript itself will generate a declaration file with export {}
even if there are no exports in the source file. See https://github.com/microsoft/TypeScript/issues/20496. In my case I might be getting an error from tsup, which I think uses this plugin. But I'm not sure where the problem actually lies.
Although typescript emitted export {}
in declaration file, It seems that rollup itself will convert export {}
to empty string.
Can we add export { }
directly to the generated emty code to avoid empty dts file:
const plugin = () => ({
renderChunk: (code) => {
if (!code) {
code += 'export { }'
}
return code
}
})
Checklist
node-resolve
are known to cause issues..d.ts
files generated by TypeScript. The plugin can consume.ts
and even.js
files (withallowJs: true
), but this is known to cause issues.@types
. The plugin ignores these by default, unlessrespectExternal
is set.@types
can contain hand-crafted code which is known to cause issues.Code Snipped
Error Message
I created a simple project (it can be found here: https://github.com/vegidio-js/template-typescript) where I'm trying to put all the type definition files created by TypeScript into a single
d.ts
file, but the generatedd.ts
file is blank.If you clone the project above and run
yarn && yarn build
then you will see the following message:This seems to be happening because my
d.ts
entrypointdist/types/index.d.ts
is blank, but all the otherd.ts
files generated by TS have something in it, but isn't this package supposed to merge all files together under a single one or did I miss something in the configuration?