tsconfig.json not found in parent of source directory (8.1.1-canary.28)
See original GitHub issueBug report
Describe the bug
In the 8.1.1 canaries with native TypeScript support, Next is assuming that tsconfig.json will be in the source directory, rather than above it.
When it doesn’t find it, it creates a blank tsconfig.json file that then doesn’t have the right configuration.
I discovered this when migrating from a working withTypescript installation of Next 8.0.
To Reproduce
Using the following directory structure:
- tsconfig.json
- next.config.js
- src/
- components/
- pages/
- build/
Where tsconfig.json has:
{
"extends": "…",
"compilerOptions": {
"rootDir": "src",
"outDir": "build",
"sourceMap": true,
"declaration": false
},
"include": [
"src/**/*"
]
}
And next.config.js:
module.exports = {
distDir: path.join('..', 'build', '.next'),
assetPrefix: process.env.ASSET_PREFIX || '/',
publicRuntimeConfig: {
},
}
Run:
$ npx next build src
Expected behavior
Next should find that there’s a tsconfig.json file in the level above src and use that, in the same way that it finds the next.config.js file.
System information
- Version of Next.js: 8.1.1-canary.28
Additional context
My existing setup worked fine with withTypescript.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (5 by maintainers)
Top Results From Across the Web
tsconfig.json not found in parent of source directory (8.1.1 ...
Bug report Describe the bug In the 8.1.1 canaries with native TypeScript support, Next is assuming that tsconfig.json will be in the source...
Read more >Warning: Cannot find parent tsconfig.json - Stack Overflow
Try setting up include section in file tsconfig.json like in below image. (Note that my project's root folder is frontend and my include ......
Read more >TSConfig Option: rootDir - TypeScript
json file. When TypeScript compiles files, it keeps the same directory structure in the output directory as exists in the input directory. For...
Read more >Understanding TypeScript's “Compilation Process” & the ...
When you run tsc command in a directory, TypeScript compiler looks for the tsconfig.json file in the current directory and if it doesn't...
Read more >Typescript Error: Cannot find parent 'tsconfig.json ... - YouTrack
this error indicates that current TypeScript file is not included in any tsconfig.json file found in the project. How many tsconfig.json files do...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Is there a way to disable Next.js’s TypeScript support? TBH I was pretty happy running things through Babel’s TypeScript handling. It made everything very consistent in development (considering how other compiling tools have good Babel support, like Jest and Storybook).
I’m nervous about how Next.js’s modifying of tsconfig.json and demands about where it is placed will affect the non-Next.js TypeScript code in my project.
I like that TS is going to be inbuild by default but agree with @fionawhim that the config property for tsconfig location should be provided. The BTW complaint is that config object API is not thoroughly described in Docs. Would be nice to have a full description of all properties like for example in Jest configuration Docs.