Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix next-types-plugin generated files for Node16/NodeNext #47571

Merged
merged 5 commits into from
Mar 30, 2023
Merged

Fix next-types-plugin generated files for Node16/NodeNext #47571

merged 5 commits into from
Mar 30, 2023

Commits on Mar 27, 2023

  1. Fix import extensions for Node16/NodeNext

    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'
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ```
    
    Adding the extensions will make it work with these projects and still maintain backwards compatibility with other TypeScript / module configurations.
    karlhorky committed Mar 27, 2023
    Configuration menu
    Copy the full SHA
    6e7a095 View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2023

  1. Configuration menu
    Copy the full SHA
    1acc1bd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cec7e98 View commit details
    Browse the repository at this point in the history
  3. Fix code style

    karlhorky committed Mar 30, 2023
    Configuration menu
    Copy the full SHA
    92b344e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    aaa1524 View commit details
    Browse the repository at this point in the history