Skip to content

Commit

Permalink
Add more extensions to next-types-plugin for Node16/NodeNext (#…
Browse files Browse the repository at this point in the history
…52562)

### What? Why? How?

Similar to #47571, add `.js` extensions to generated imports to avoid problems with TypeScript `Node16` / `NodeNext` module resolution

Without this change, there are confusing errors with `{ experimental: { typedRoutes: true } }` in `next.config.js`, such as:

```
Property 'refresh' does not exist on type 'AppRouterInstance'.ts(2339)
```

<img width="490" alt="Screenshot 2023-07-11 at 19 12 21" src="https://github.com/vercel/next.js/assets/1935696/399265e6-223d-4386-bc85-6136d98e436a">

cc @shuding
  • Loading branch information
karlhorky committed Jul 12, 2023
1 parent b7e2627 commit 2b98f77
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,15 @@ declare namespace __next_route_internal_types__ {
}
declare module 'next' {
export { default } from 'next/types'
export * from 'next/types'
export { default } from 'next/types/index.js'
export * from 'next/types/index.js'
export type Route<T extends string = string> =
__next_route_internal_types__.RouteImpl<T>
}
declare module 'next/link' {
import type { LinkProps as OriginalLinkProps } from 'next/dist/client/link'
import type { LinkProps as OriginalLinkProps } from 'next/dist/client/link.js'
import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'
import type { UrlObject } from 'url'
Expand Down Expand Up @@ -440,9 +440,9 @@ declare module 'next/link' {
}
declare module 'next/navigation' {
export * from 'next/dist/client/components/navigation'
export * from 'next/dist/client/components/navigation.js'
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context'
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.js'
interface AppRouterInstance extends OriginalAppRouterInstance {
/**
* Navigate to the provided href.
Expand Down

0 comments on commit 2b98f77

Please sign in to comment.