Add typechecking test for all entrypoints (#64478)
This commit is contained in:
parent
2be9ccb658
commit
edb9f7a142
6 changed files with 91 additions and 0 deletions
28
test/production/typescript-basic/typechecking.test.ts
Normal file
28
test/production/typescript-basic/typechecking.test.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import * as childProcess from 'child_process'
|
||||
import path from 'path'
|
||||
import { FileRef, nextTestSetup } from 'e2e-utils'
|
||||
|
||||
describe('typechecking', () => {
|
||||
const { next } = nextTestSetup({
|
||||
files: new FileRef(path.join(__dirname, 'typechecking')),
|
||||
skipStart: true,
|
||||
})
|
||||
|
||||
it('should typecheck', async () => {
|
||||
const { status, stdout } = childProcess.spawnSync(
|
||||
'pnpm',
|
||||
['tsc', '--project', 'tsconfig.json', '--skipLibCheck', 'false'],
|
||||
{
|
||||
cwd: next.testDir,
|
||||
encoding: 'utf-8',
|
||||
}
|
||||
)
|
||||
|
||||
if (status !== 0) {
|
||||
// Piped output is incomplete and the format barely useable.
|
||||
// Printing it as a last resort in case it's not reproducible locally.
|
||||
// Best to NEXT_TEST_SKIP_CLEANUP=1 this test and run the command in the app localy.
|
||||
throw new Error('Typecheck failed: \n' + stdout)
|
||||
}
|
||||
})
|
||||
})
|
1
test/production/typescript-basic/typechecking/.gitignore
vendored
Normal file
1
test/production/typescript-basic/typechecking/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!next-env.d.ts
|
25
test/production/typescript-basic/typechecking/index.ts
Normal file
25
test/production/typescript-basic/typechecking/index.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import 'next/amp'
|
||||
import 'next/app'
|
||||
// FIXME
|
||||
// import 'next/babel';
|
||||
import 'next/cache'
|
||||
import 'next/client'
|
||||
import 'next/config'
|
||||
import 'next/constants'
|
||||
import 'next/document'
|
||||
import 'next/dynamic'
|
||||
import 'next/error'
|
||||
import 'next/head'
|
||||
import 'next/headers'
|
||||
import 'next/image'
|
||||
import 'next'
|
||||
// TODO @jest/types is an undeclared peer dependecy
|
||||
// import 'next/jest';
|
||||
import 'next/link'
|
||||
import 'next/navigation'
|
||||
import 'next/og'
|
||||
import 'next/router'
|
||||
import 'next/script'
|
||||
import 'next/server'
|
||||
// FIXME
|
||||
// import 'next/web-vitals';
|
5
test/production/typescript-basic/typechecking/next-env.d.ts
vendored
Normal file
5
test/production/typescript-basic/typechecking/next-env.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
|
@ -0,0 +1,6 @@
|
|||
/**
|
||||
* @type {import('next').NextConfig}
|
||||
*/
|
||||
const nextConfig = {}
|
||||
|
||||
module.exports = nextConfig
|
26
test/production/typescript-basic/typechecking/tsconfig.json
Normal file
26
test/production/typescript-basic/typechecking/tsconfig.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": false,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
Loading…
Reference in a new issue