Typescript: Using @nuxt/typescript overrides any existing tsconfig.json file

Created on 22 Mar 2019  路  3Comments  路  Source: nuxt/typescript

Version

v2.5.1

Reproduction link

https://codesandbox.io/s/0qmykr7wq0

Steps to reproduce

Using the official Nuxt with TypeScript example on CodeSandbox:

  • Adjust the tsconfig.json in any way
  • Restart the sandbox

TS support will be detected again and any modifications to tsconfig.json will be overridden.

What is expected ?

The existing tsconfig.json is unmodified.

What is actually happening?

The tsconfig.json content is overridden.

Additional comments?

I've also noticed that the generation of the tsconfig.json doesn't seem to respect the srcDir setting in the Nuxt config.

For some background: we have a setup where we use TS for our server-side code and our Nuxt code in the same repo. At present, we have a tsconfig.json in the root for our server code and then a separate tsconfig.json for our Nuxt setup in a subdirectory (which is ignored by the first config file).

Since 2.5.0 our root tsconfig.json is being overridden by the automatically generated one. I don't think this would cause any issues if it respected the srcDir config option (i.e. generated it in the subdirectory) although it seems feasible to me that people may want to modify their config and overriding it every time may not be the best option.

This bug report is available on Nuxt community (#c8900)
transfered

Most helpful comment

Hi @sambowler, we're gonna switch back to the old behavior which was extending a tsconfig.json.

Overriding tsconfig.json is indeed not the best idea (FYI it doesn't exactly override but add missing values in it).

The main issue we have is that we need to take root tsconfig.json for runTime support (nuxt.config.ts / serverMiddlewares), and tsconfig.json from srcDir for webpack related TS files (vue components, plugins).

Thanks for your feedback, it will be closely taken into account. I will refer this issue when I'll open the PR which brings better TS integration.

All 3 comments

Hi @sambowler, we're gonna switch back to the old behavior which was extending a tsconfig.json.

Overriding tsconfig.json is indeed not the best idea (FYI it doesn't exactly override but add missing values in it).

The main issue we have is that we need to take root tsconfig.json for runTime support (nuxt.config.ts / serverMiddlewares), and tsconfig.json from srcDir for webpack related TS files (vue components, plugins).

Thanks for your feedback, it will be closely taken into account. I will refer this issue when I'll open the PR which brings better TS integration.

@kevinmarrec
Since latest it doesn't like "extends": "@nuxt/typescript-edge", line in tsconfig.json. What is the right value for that?

Thanks in advance

@husayt, just removing it should work

Was this page helpful?
0 / 5 - 0 ratings