https://codesandbox.io/s/nuxt-tsconfig-issue-sample-zkx3o
yarn dev
Note that this sandbox is in the state of before first run, so tsconfig.json is a just empty file.
Nuxt will create content of tsconfig.json automatically, and dev build will continue successfully.
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.
@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:
Issues that are labeled as pending will not be automatically marked as stale.
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
baseUrlis automatically updated with rightsrcDirwith upcoming TypeScript support externalization.