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.js type references in Next.js >= 13.2.0 #21304

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Feb 28, 2023

Closes N/A

What I did

Added some type references for Next.js stories, since they are necessary since Next.js 13.2.0, because some types in next/navigation are not exported per default, but type references are dynamically created during Next.js start up instead. See vercel/next.js@cdf1d52 for more insights.

How to test

  1. Run a Next.js sandbox: yarn task --task sandbox --template nextjs/default-ts
  2. Go to your sandbox directory
  3. Open next.config.js and add { experimental: { appDir: true }} to the configuration
  4. Add a empty app folder in the sandbox
  5. Start Next.js once (yarn dev) and abort it after it started successfully
  6. A next-env.d.ts should be created with these entries:
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
  1. Open stories/frameworks/nextjs_default-ts/Navigation.stories.tsx -> The import shouldn't error.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@valentinpalkovic valentinpalkovic added bug ci:daily Run the CI jobs that normally run in the daily job. labels Feb 28, 2023
@valentinpalkovic valentinpalkovic self-assigned this Feb 28, 2023
Added some type references for Next.js stories, since they are necessary since Next.js 13.2.0,
because some types in `next/navigation` are not exported per default, but
type references are dynamically created during Next.js start up.
See vercel/next.js@cdf1d52
for more insights.
@valentinpalkovic valentinpalkovic force-pushed the valentin/fix-next-js-types-in-13.2.0 branch from a9f301c to 9ba7f94 Compare February 28, 2023 17:21
@valentinpalkovic valentinpalkovic changed the title Fix Next.js type references in Next.js > 13.2.0 Fix Next.js type references in Next.js >= 13.2.0 Mar 1, 2023
Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@valentinpalkovic valentinpalkovic merged commit 31c97a2 into next Mar 1, 2023
@valentinpalkovic valentinpalkovic deleted the valentin/fix-next-js-types-in-13.2.0 branch March 1, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ci:daily Run the CI jobs that normally run in the daily job.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants