question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tsconfig.json not found in parent of source directory (8.1.1-canary.28)

See original GitHub issue

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 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
fionawhimcommented, May 15, 2019

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.

1reaction
mifrejcommented, May 17, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found