Skip to content

Commit c5840d6

Browse files
committed
Add typechecking test for all entrypoints
1 parent 33e8334 commit c5840d6

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as childProcess from 'child_process'
2+
import path from 'path'
3+
import { FileRef, nextTestSetup } from 'e2e-utils'
4+
5+
describe('typechecking', () => {
6+
const { next } = nextTestSetup({
7+
files: new FileRef(path.join(__dirname, 'typechecking')),
8+
skipStart: true,
9+
})
10+
11+
it('should typecheck', async () => {
12+
const { status, stdout } = childProcess.spawnSync(
13+
'pnpm',
14+
['tsc', '--project', 'tsconfig.json', '--skipLibCheck', 'false'],
15+
{
16+
cwd: next.testDir,
17+
encoding: 'utf-8',
18+
}
19+
)
20+
21+
if (status !== 0) {
22+
// Piped output is incomplete and the format barely useable.
23+
// Printing it as a last resort in case it's not reproducible locally.
24+
// Best to NEXT_TEST_SKIP_CLEANUP=1 this test and run the command in the app localy.
25+
throw new Error('Typecheck failed: \n' + stdout)
26+
}
27+
})
28+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!next-env.d.ts
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import 'next/amp'
2+
import 'next/app'
3+
// FIXME
4+
// import 'next/babel';
5+
import 'next/cache'
6+
import 'next/client'
7+
import 'next/config'
8+
import 'next/constants'
9+
import 'next/document'
10+
import 'next/dynamic'
11+
import 'next/error'
12+
import 'next/head'
13+
import 'next/headers'
14+
import 'next/image'
15+
import 'next'
16+
// TODO @jest/types is an undeclared peer dependecy
17+
// import 'next/jest';
18+
import 'next/link'
19+
import 'next/navigation'
20+
import 'next/og'
21+
import 'next/router'
22+
import 'next/script'
23+
import 'next/server'
24+
// FIXME
25+
// import 'next/web-vitals';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @type {import('next').NextConfig}
3+
*/
4+
const nextConfig = {}
5+
6+
module.exports = nextConfig
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["dom", "dom.iterable", "esnext"],
4+
"allowJs": true,
5+
"skipLibCheck": false,
6+
"strict": true,
7+
"noEmit": true,
8+
"esModuleInterop": true,
9+
"module": "esnext",
10+
"moduleResolution": "bundler",
11+
"resolveJsonModule": true,
12+
"isolatedModules": true,
13+
"jsx": "preserve",
14+
"incremental": true,
15+
"plugins": [
16+
{
17+
"name": "next"
18+
}
19+
],
20+
"paths": {
21+
"@/*": ["./*"]
22+
}
23+
},
24+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25+
"exclude": ["node_modules"]
26+
}

0 commit comments

Comments
 (0)