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.

tsconfig `include` not overridden

See original GitHub issue

#It’s either a bug or maybe a wanted functionality. Here are my tsconfig file and plugin options which work well: tsconfig.dist.esm.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "declaration": true,
    "declarationDir": "dist/esm"
  },
  "include": ["src/**/*.ts"]
}

rollup.config.js:

typescript({
  tsconfig: 'tsconfig.dist.esm.json',
  useTsconfigDeclarationDir: true
})

I wanted to rid of tsconfig.dist.esm.json and thus modified rollup.config.js file:

typescript({
  tsconfig: 'tsconfig.dist.esm.json',
  tsconfigOverride: {
    compilerOptions: {
      declaration: true,
      declarationDir: 'dist/esm'
    },
    include: ['src/**/*.ts']
  },
  useTsconfigDeclarationDir: true
})

But it does not work. The plugin does not pay attention to txconfigOverride.compilerOptions.declarationDir option. Would be nice if it could.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kalitinecommented, Oct 25, 2017

Ok, I see. Yes override confused me. No problem I will preserve my tsconfig.dist.esm.json which extends tsconfig.json and is not a big deal.

1reaction
ezolenkocommented, Oct 24, 2017

Ah, yes, that works as coded. Objects and arrays are merged, not replaced. This is a different behavior from tsconfig extends option (and I probably shouldn’t have called it override 😃). Arguably either way is useful in different cases.

You can achieve what you want by creating tsconfig.base.json file without test/**/* in includes (but with all the other common options) and using that for rollup directly. Then create tsconfig.json that extends your base and specifies full include list and use that outside of rollup. (see Configuration inheritance in tsconfig-json)

Doesn’t reduce number of files, but removes duplication.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending a typescript file's "include" without overriding ...
Is it possible to include a json file when using TypeScript with a tsconfig.json file? 390 · Cannot use JSX unless the '--jsx'...
Read more >
TSConfig Reference - Docs on every TSConfig option
Using noImplicitOverride you can ensure that the sub-classes never go out of sync, by ensuring that functions which override include the keyword override...
Read more >
tsconfig.json parameters cannot be extended, only overwritten
My experience learning how the "extends" option in tsconfig handles overriding array parameters when creating a global definitions file for ...
Read more >
Module type overrides | ts-node - TypeStrong · GitHub
Globs are also supported with the same behavior as tsconfig "include" ... For example, a webpack.config.ts cannot be given its own package.json to...
Read more >
Introducing Typescript `override` keyword
Now, Typescript will throw an error if an overridden method does not include the override keyword. I hope you learned a bit about...
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