question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support disabling of declarations generation

See original GitHub issue

Just thinking. Currently, we can make multiple Rollup configs using this plugin. So, it will output cjs, esm, and umd bundles for example.

But for all of them, it will also create exactly the same index.d.ts files, which is unnecessary duplication and increase of the published npm package size.

The workaround is to pass declarationDir: 'types' in your tsconfig, but it will throw

[!] (plugin Typescript) TS5055: Cannot write file '/home/charlike/github/tunnckoCore/configs/types/index.d.ts' because it would overwrite input file.

if you have such as the above scenario. And this error makes sense, because what really happening is the following: “okey, a cjs bundle, write index.d.ts; then esm bundle, write index.d.ts”. It throws because after the first bundling process is finished there is already generated types/index.d.ts file.


While writing the issues, just realized that I there might be one more workaround: use the tsconfig option (object) instead of depending on the project root tsconfig.json file, which is automatically detected - so it will be used only for editors support.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
domoritzcommented, Sep 7, 2020

Right, so it would be the inverse if your tsconfig doesn’t set declaration.

const tsconfig = require('./tsconfig.json').compilerOptions;

...
  ts({
    tsconfig: {
      ...tsconfig,
      declaration: true
    }
  })
...

My use case is as the one described in the beginning where I generate multiple bundles but I only need one declaration file.

1reaction
domoritzcommented, Sep 7, 2020

Thanks for providing a solution @tunnckoCore. I wonder whether it makes sense to add an option to rollup-plugin-ts to disable declaration files. I definitely think it’s a common use case. What do you think @wessberg?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Disable Automatic Declaration? - Forums - IBM Support
I know I disabled automatic declaration in DOORS 8.2. Upon moving to DOORS 9.3, I must have lost the setting. The problem is...
Read more >
TSConfig Reference - Docs on every TSConfig option
#Editor Support. # Disable Size Limit - disableSizeLimit. To avoid a possible memory bloat issues when working with very large JavaScript projects ...
Read more >
Can not emit declaration files for TypeScript #1081 - GitHub
Declaration files are only relevant when generating a library consumable by a package manager. The build time overhead would only happen in this ......
Read more >
Disabling ID field generation for Mongoose alternate ...
I'd like to use this form, but disable the autogenerated ID property of the embedded object. Is there a way to do this?...
Read more >
Configuring in place records management - Microsoft Support
... further disable manual declaration of records at the list or library level. ... the creation of records within specific lists or libraries...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found