Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure moduleResolution is written correctly (#39836)
This removes the usage of `Node12` from the `parsedValues` for `moduleResolution` as this caused false detection of `undefined` being a valid value when it was removed in TypeScript. This also copies over the test from #37302 to ensure we don't regress on this. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` Fixes: #37296 Closes: #37302
- Loading branch information
Showing
2 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { createNext } from 'e2e-utils' | ||
import fs from 'fs' | ||
import { waitFor } from 'next-test-utils' | ||
import path from 'path' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
|
||
describe('correct tsconfig.json defaults', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
'pages/index.tsx': 'export default function Page() {}', | ||
}, | ||
skipStart: true, | ||
dependencies: { | ||
typescript: 'latest', | ||
'@types/react': 'latest', | ||
'@types/node': 'latest', | ||
}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should add `moduleResoution` when generating tsconfig.json in dev', async () => { | ||
const tsconfigPath = path.join(next.testDir, 'tsconfig.json') | ||
expect(fs.existsSync(tsconfigPath)).toBeFalse() | ||
|
||
await next.start() | ||
await waitFor(1000) | ||
await next.stop() | ||
|
||
expect(fs.existsSync(tsconfigPath)).toBeTrue() | ||
|
||
const tsconfig = JSON.parse(await next.readFile('tsconfig.json')) | ||
|
||
expect(tsconfig.compilerOptions).toEqual( | ||
expect.objectContaining({ moduleResolution: 'node' }) | ||
) | ||
}) | ||
}) |