diff --git a/test/production/typescript-basic/typechecking.test.ts b/test/production/typescript-basic/typechecking.test.ts new file mode 100644 index 0000000000000..d93d64ef54ef3 --- /dev/null +++ b/test/production/typescript-basic/typechecking.test.ts @@ -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) + } + }) +}) diff --git a/test/production/typescript-basic/typechecking/.gitignore b/test/production/typescript-basic/typechecking/.gitignore new file mode 100644 index 0000000000000..6fcb2e11a6257 --- /dev/null +++ b/test/production/typescript-basic/typechecking/.gitignore @@ -0,0 +1 @@ +!next-env.d.ts \ No newline at end of file diff --git a/test/production/typescript-basic/typechecking/index.ts b/test/production/typescript-basic/typechecking/index.ts new file mode 100644 index 0000000000000..69404ba3014e2 --- /dev/null +++ b/test/production/typescript-basic/typechecking/index.ts @@ -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'; diff --git a/test/production/typescript-basic/typechecking/next-env.d.ts b/test/production/typescript-basic/typechecking/next-env.d.ts new file mode 100644 index 0000000000000..4f11a03dc6cc3 --- /dev/null +++ b/test/production/typescript-basic/typechecking/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/test/production/typescript-basic/typechecking/next.config.js b/test/production/typescript-basic/typechecking/next.config.js new file mode 100644 index 0000000000000..807126e4cf0bf --- /dev/null +++ b/test/production/typescript-basic/typechecking/next.config.js @@ -0,0 +1,6 @@ +/** + * @type {import('next').NextConfig} + */ +const nextConfig = {} + +module.exports = nextConfig diff --git a/test/production/typescript-basic/typechecking/tsconfig.json b/test/production/typescript-basic/typechecking/tsconfig.json new file mode 100644 index 0000000000000..8f01956e620c8 --- /dev/null +++ b/test/production/typescript-basic/typechecking/tsconfig.json @@ -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"] +}