Unverified Commit 5cc90102 authored by teobler's avatar teobler Committed by GitHub

fix: distDir in verifyTypeScriptSetup for nextLint (#46630)

fixes #46611 

this PR fixed customer dist type(`distDir` option in next.config.js) in
`tsconfig.json` will be a hard coded absolute path issue which is a bug
from PR #46249
since dist type only be added when user using app dir, to reproduce this
issue you need to make `app dir` toggle on and add a `distDir` option in
`next.config.js` file

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

---------
parent dd2a1c69
......@@ -205,7 +205,7 @@ const nextLint: CliCommand = async (argv) => {
await verifyTypeScriptSetup({
dir: baseDir,
distDir,
distDir: nextConfig.distDir,
intentDirs: [pagesDir, appDir].filter(Boolean) as string[],
typeCheckPreflight: false,
tsconfigPath: nextConfig.typescript.tsconfigPath,
......
......@@ -383,6 +383,24 @@ describe('ESLint', () => {
})
}
test('should add relative path for dist types in tsconfig.json when app dir exist', async () => {
await nextLint(dirTypescript, [], {
stdout: true,
stderr: true,
})
const tsConfigPath = join(
dirTypescript,
'../with-typescript/tsconfig.json'
)
const tsConfigContent = await fs.readFile(tsConfigPath, {
encoding: 'utf8',
})
const tsConfigJson = JSON.parse(tsConfigContent)
expect(tsConfigJson.include).toContain('.build/types/**/*.ts')
})
test('shows warnings and errors', async () => {
const { stdout, stderr } = await nextLint(dirCustomConfig, [], {
stdout: true,
......
export default function Layout({ children }) {
return (
<html>
<head>
<title>Next.js lint test with TypeScript</title>
</head>
<body>
<main>{children}</main>
</body>
</html>
)
}
module.exports = {
experimental: {
appDir: true,
},
distDir: '.build',
}
import React from 'react'
const Home = () => (
<div>
<p>Home</p>
......
......@@ -12,8 +12,14 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
],
"strictNullChecks": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".build/types/**/*.ts"],
"exclude": ["node_modules"]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment