Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What / Why / How? In a project with `"type": "module"` in `package.json` and a `compilerOptions.moduleResolution` of `Node16` or `NodeNext` in `tsconfig.json`, running `tsc` will yield errors like the following: ``` .next/types/app/[...not_found]/page.ts:1:40 - error TS2307: Cannot find module 'next/dist/lib/metadata/types/metadata-interface' or its corresponding type declarations. 1 import type { ResolvingMetadata } from 'next/dist/lib/metadata/types/metadata-interface'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .next/types/app/layout.ts:2:24 - error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '../../../app/layout.jsx'? 2 import * as entry from '../../../app/layout' ~~~~~~~~~~~~~~~~~~~~~ .next/types/app/layout.ts:3:40 - error TS2307: Cannot find module 'next/dist/lib/metadata/types/metadata-interface' or its corresponding type declarations. 3 import type { ResolvingMetadata } from 'next/dist/lib/metadata/types/metadata-interface' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` These files are checked because of the following `tsconfig.json` line which Next.js adds: ```diff { "include": [ + ".next/types/**/*.ts", ] } ``` Adding the extensions will make it work with these projects and still maintain backwards compatibility with other TypeScript / module configurations.
- Loading branch information