`include` in `tsconfigDefaults` is overridden by index from original tsconfig.json
See original GitHub issueWhat 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
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:
- Created 3 years ago
- Comments:28 (4 by maintainers)
Top GitHub Comments
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 intotsconfig
- this is the object that we get from typescript, after its own imports and everything. All values here replace values intsconfigDefaults
. All arrays here are concatenated with arrays intsconfigDefaults
.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?
@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.