Typescript: tsconfig.json does not reflect config.srcDir

Created on 17 Jun 2019  路  4Comments  路  Source: nuxt/typescript

Version

v2.8.1

Reproduction link

https://codesandbox.io/s/nuxt-tsconfig-issue-sample-zkx3o

Steps to reproduce

yarn dev

Note that this sandbox is in the state of before first run, so tsconfig.json is a just empty file.

What is expected ?

Nuxt will create content of tsconfig.json automatically, and dev build will continue successfully.

What is actually happening?

tsconfig.json is created with "baseUrl": "." even config.srcDir is set to src, and type check for import MyComponent from '~/components/MyComponent.vue' in src/pages/index.vue fails.

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

Most helpful comment

(Don't pay attention of the referenced pull-request, it's just to ping its author so he understand a little more why his PR can't work)

Alright, I'll see if we can ensure that baseUrl is automatically updated with right srcDir with upcoming TypeScript support externalization.

All 4 comments

@nandenjin It's a limitation we have for now, the issue is that a tsconfig.jsonis needed to be able to read ts files, and nuxt.config.ts is one of them. So we can't read config before setup TypeScript (ts-node which make able to transpile TS files).

Something we could do is generate tsconfig.json, read config, and then rewrite tsconfig.json to override baseUrl property with right srcDir. /cc @pi0 baseUrl override could be done by @nuxt/typescript-build module.

You can fix your project by manually editing the generated tsconfig.json baseUrl property with :

"baseUrl": "src"

If it doesn't work please try changing paths property and give feedback, so we know what are the guidelines for custom srcDir.

@kevinmarrec
I understand, currently I fix baseUrl manually as you mentioned in all of my projects, and they work well for me. Thanks.

(Don't pay attention of the referenced pull-request, it's just to ping its author so he understand a little more why his PR can't work)

Alright, I'll see if we can ensure that baseUrl is automatically updated with right srcDir with upcoming TypeScript support externalization.

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

Was this page helpful?
0 / 5 - 0 ratings