This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning for older TypeScript versions (vercel#25867)
- Loading branch information
Showing
6 changed files
with
116 additions
and
0 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
5 changes: 5 additions & 0 deletions
5
test/integration/typescript-version-warning/app/node_modules/typescript/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
test/integration/typescript-version-warning/app/node_modules/typescript/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
test/integration/typescript-version-warning/app/pages/index.tsx
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,3 @@ | ||
export default function Page(props) { | ||
return <p>hello world</p> | ||
} |
19 changes: 19 additions & 0 deletions
19
test/integration/typescript-version-warning/app/tsconfig.json
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": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": false, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve" | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
76 changes: 76 additions & 0 deletions
76
test/integration/typescript-version-warning/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,76 @@ | ||
/* eslint-env jest */ | ||
import fs from 'fs-extra' | ||
import { join } from 'path' | ||
import { nextBuild, findPort, launchApp, killApp } from 'next-test-utils' | ||
|
||
jest.setTimeout(1000 * 60 * 2) | ||
|
||
const appDir = join(__dirname, '../app') | ||
|
||
describe('Minimum TypeScript Warning', () => { | ||
it('should show warning during next build with old version', async () => { | ||
const res = await nextBuild(appDir, [], { | ||
stderr: true, | ||
stdout: true, | ||
}) | ||
expect(res.stdout + res.stderr).toContain( | ||
'Minimum recommended TypeScript version is' | ||
) | ||
}) | ||
|
||
it('should show warning during next dev with old version', async () => { | ||
let output = '' | ||
|
||
const handleOutput = (msg) => { | ||
output += msg | ||
} | ||
const app = await launchApp(appDir, await findPort(), { | ||
onStdout: handleOutput, | ||
onStderr: handleOutput, | ||
}) | ||
await killApp(app) | ||
|
||
expect(output).toContain('Minimum recommended TypeScript version is') | ||
}) | ||
|
||
it('should not show warning during next build with new version', async () => { | ||
await fs.rename( | ||
join(appDir, 'node_modules/typescript'), | ||
join(appDir, 'node_modules/typescript-back') | ||
) | ||
const res = await nextBuild(appDir, [], { | ||
stderr: true, | ||
stdout: true, | ||
}) | ||
await fs.rename( | ||
join(appDir, 'node_modules/typescript-back'), | ||
join(appDir, 'node_modules/typescript') | ||
) | ||
expect(res.stdout + res.stderr).toContain( | ||
'Minimum recommended TypeScript version is' | ||
) | ||
}) | ||
|
||
it('should not show warning during next dev with new version', async () => { | ||
let output = '' | ||
|
||
const handleOutput = (msg) => { | ||
output += msg | ||
} | ||
await fs.rename( | ||
join(appDir, 'node_modules/typescript'), | ||
join(appDir, 'node_modules/typescript-back') | ||
) | ||
const app = await launchApp(appDir, await findPort(), { | ||
onStdout: handleOutput, | ||
onStderr: handleOutput, | ||
}) | ||
await killApp(app) | ||
await fs.rename( | ||
join(appDir, 'node_modules/typescript-back'), | ||
join(appDir, 'node_modules/typescript') | ||
) | ||
|
||
expect(output).toContain('Minimum recommended TypeScript version is') | ||
}) | ||
}) |