-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration flags to disable integrated type checker (#9138)
* Add a configuration flag to disable integrated type checker * Add tests for typescript-transpileonly * Restore removed argument * Make output more coherent * Split transpileOnly into ignoreDevErrors and ignoreBuildErrors * Minor stylistic change
- Loading branch information
Showing
9 changed files
with
144 additions
and
3 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
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
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 @@ | ||
module.exports = {} |
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,2 @@ | ||
// Below type error is intentional, it helps check typescript → ignoreDevErrors / ignoreBuildErrors flags in next.config.js | ||
export default (): boolean => 'Index page' |
84 changes: 84 additions & 0 deletions
84
test/integration/typescript-ignore-errors/test/index.test.js
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,84 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import { join } from 'path' | ||
import { | ||
renderViaHTTP, | ||
nextBuild, | ||
findPort, | ||
launchApp, | ||
killApp, | ||
File | ||
} from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 | ||
|
||
const appDir = join(__dirname, '..') | ||
const nextConfigFile = new File(join(appDir, 'next.config.js')) | ||
|
||
describe('TypeScript with error handling options', () => { | ||
for (const ignoreDevErrors of [false, true]) { | ||
for (const ignoreBuildErrors of [false, true]) { | ||
describe(`ignoreDevErrors: ${ignoreDevErrors}, ignoreBuildErrors: ${ignoreBuildErrors}`, () => { | ||
beforeAll(() => { | ||
const nextConfig = { | ||
typescript: { ignoreDevErrors, ignoreBuildErrors } | ||
} | ||
nextConfigFile.replace('{}', JSON.stringify(nextConfig)) | ||
}) | ||
afterAll(() => { | ||
nextConfigFile.restore() | ||
}) | ||
|
||
it( | ||
ignoreDevErrors | ||
? 'Next renders the page in dev despite type errors' | ||
: 'Next dev does not render the page in dev because of type errors', | ||
async () => { | ||
let app | ||
let output = '' | ||
try { | ||
const appPort = await findPort() | ||
app = await launchApp(appDir, appPort, { | ||
onStdout: msg => (output += msg), | ||
onStderr: msg => (output += msg) | ||
}) | ||
await renderViaHTTP(appPort, '') | ||
|
||
if (ignoreDevErrors) { | ||
expect(output).not.toContain('waiting for typecheck results...') | ||
expect(output).not.toContain("not assignable to type 'boolean'") | ||
} else { | ||
expect(output).toContain('waiting for typecheck results...') | ||
expect(output).toContain("not assignable to type 'boolean'") | ||
} | ||
} finally { | ||
await killApp(app) | ||
} | ||
} | ||
) | ||
|
||
it( | ||
ignoreBuildErrors | ||
? 'Next builds the application despite type errors' | ||
: 'Next fails to build the application despite type errors', | ||
async () => { | ||
const { stdout, stderr } = await nextBuild(appDir, [], { | ||
stdout: true, | ||
stderr: true | ||
}) | ||
|
||
if (ignoreBuildErrors) { | ||
expect(stdout).toContain('Compiled successfully') | ||
expect(stderr).not.toContain('Failed to compile.') | ||
expect(stderr).not.toContain("not assignable to type 'boolean'") | ||
} else { | ||
expect(stdout).not.toContain('Compiled successfully') | ||
expect(stderr).toContain('Failed to compile.') | ||
expect(stderr).toContain("not assignable to type 'boolean'") | ||
} | ||
} | ||
) | ||
}) | ||
} | ||
} | ||
}) |
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,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"jsx": "preserve", | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["next-env.d.ts", "pages"] | ||
} |
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