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.

`include` in `tsconfigDefaults` is overridden by index from original tsconfig.json

See original GitHub issue

What happens and why it is wrong

That bug is really weird. At some point, I started getting a weird error caused by include option of typescript2 config and project tsconfig.json. I even stopped understanding how it works, does it override or concatenate, or what? then, I decided that I need to debug this array to check what finally gets there

My rollup-plugin-typescript2 config:

  typescript2({
      clean: true,
      tsconfigDefaults: {
        ....
        include: [path.resolve(__dirname, 'styles.d.ts')],
      }
    }),

My tsconfig.json config:

   ...
  "include": ["src", "declaration.d.ts"]
}

The result is Screenshot 2020-05-07 at 19 44 57

As I said before, I started debugging this it gives some kind of awkward result every time. In fact, it does not concatenate these properties, but replaces the values in the index cell, which simply takes by surprise and worsens developer experience.

What I mean: it takes 0 the index of the array of my tsconfig and puts it instead of the value under the 0 index of typescript2 config.

Example 1:

typescript2: ['a']
tsconfig: ['b', 'c']
result: ['b', 'c']

Example 2:

typescript2: ['a', 'd']
tsconfig: ['b', 'c']
result: ['b', 'c']

Example 3:

typescript2: ['a', 'd', 'e']
tsconfig: ['b', 'c']
result: ['b', 'c', 'e']

It is completely annoying

Environment

I’m not sure this is relevant, but Node: 13.13.0 OS: macOS Catalina 10.15.4

Versions

  • typescript: 3.8.3
  • rollup: 2.8.1
  • rollup-plugin-typescript2: 0.27.0

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
ezolenkocommented, May 23, 2020

I think we’ll have to break things no matter what we do here. To make it behave according to the spirit of documentation and property names it should do basically this:

  • tsconfigDefaults - this is the object everything below will be deeply merged into
  • tsconfig - this is the object that we get from typescript, after its own imports and everything. All values here replace values in tsconfigDefaults. All arrays here are concatenated with arrays in tsconfigDefaults.
  • tsconfigOverride - this is the nuclear option. Objects are still merged deeply, but arrays here replace arrays wholesale. So if you provide an empty include array here, final tsconfig will have no includes at all.

Will that cover all the cases we want to support (after users make appropriate changes), or am I missing something?

1reaction
ezolenkocommented, May 26, 2020

@maktarsis how in your approach would dev be able to remove include or exclude entries from tsconfig? The scenario is: you have a tsconfig.json that is used elsewhere, you want to use it in rollup without touching json itself, but you want to remove a line from excludes array for some reason.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
The configuration from the base file are loaded first, then overridden by those in the inheriting config file. All relative paths found in...
Read more >
How to configure react-script so that it doesn't override ...
Put the configuration options react scripts likes to remove in a separate file (e.g. ... the first step is to extend the tsconfig.json...
Read more >
Rollup Plugin Typescript2: Compile TypeScript V2.0+. - Morioh
tsconfig.json , but will not fail if file is missing unless the value is set explicitly. tsconfigOverride : {}. See tsconfigDefaults . check...
Read more >
esbuild tsconfig paths
Tsconfig paths Projects scaffolded via create-vue include pre-configured tsconfig.json. A tag already exists with the provided branch name.
Read more >
rollup-plugin-typescript2
I tried with clean: true , I tried to add typescript: ... Currently the option abortOnError: true aborts on the first error it...
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