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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/frameworks/nextjs/template/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Reference necessary since Next.js 13.2.0, because types in `next/navigation` are not exported per default, but
yannbf marked this conversation as resolved.
Show resolved Hide resolved
// type references are dynamically created during Next.js start up.
// See https://github.com/vercel/next.js/commit/cdf1d52d9aed42d01a46539886a4bda14cb77a99
// for more insights.

/// <reference types="next" />
/// <reference types="next/navigation-types/navigation" />
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function Component() {
const segment = useSelectedLayoutSegment();
const segments = useSelectedLayoutSegments();

const searchParamsList = Array.from(searchParams.entries());
const searchParamsList = searchParams ? Array.from(searchParams.entries()) : [];

const routerActions = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// usePathname and useSearchParams are only usable if experimental: {appDir: true} is set in next.config.js
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';
Expand All @@ -7,7 +8,7 @@ function Component() {
const pathname = usePathname();
const searchParams = useSearchParams();

const searchParamsList = Array.from(searchParams.entries());
const searchParamsList = searchParams ? Array.from(searchParams.entries()) : [];

const routerActions = [
{
Expand Down