From b58da75a6931d64b11a2bd4fb6c06deacb687349 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:48:50 +1000 Subject: [PATCH] docs(examples): Modernise Next.js examples (#7706) * docs(examples): Update react/auto-refetching * Update infinite-query-with-max-pages, load-more-infinite-scroll * Upgrade react/nextjs * More projects * Update playground * Update prefetching * Cleanup deps * Disable typescript during next build * Fix eslint plugin * Final changes --- docs/config.json | 2 +- .../package.json | 4 +- examples/react/auto-refetching/next-env.d.ts | 5 + examples/react/auto-refetching/next.config.js | 3 + examples/react/auto-refetching/package.json | 6 +- .../src/pages/api/{data.js => data.ts} | 7 +- .../src/pages/{index.js => index.tsx} | 14 +- examples/react/auto-refetching/tsconfig.json | 19 ++ .../next-env.d.ts | 5 + .../next.config.js | 3 + .../package.json | 9 +- .../pages/api/{projects.js => projects.ts} | 5 +- .../src/pages/{index.js => index.tsx} | 2 +- .../tsconfig.json | 19 ++ .../load-more-infinite-scroll/next-env.d.ts | 5 + .../load-more-infinite-scroll/next.config.js | 3 + .../load-more-infinite-scroll/package.json | 6 +- .../src/pages/{about.js => about.tsx} | 0 .../pages/api/{projects.js => projects.ts} | 5 +- .../src/pages/{index.js => index.tsx} | 12 +- .../load-more-infinite-scroll/tsconfig.json | 19 ++ .../nextjs-app-prefetching/next.config.js | 3 + .../react/nextjs-app-prefetching/package.json | 5 +- .../nextjs-suspense-streaming/next.config.js | 3 + .../nextjs-suspense-streaming/package.json | 4 +- examples/react/nextjs/next-env.d.ts | 5 + examples/react/nextjs/next.config.js | 3 + examples/react/nextjs/package.json | 9 +- .../{Header/index.js => Header.tsx} | 0 .../{InfoBox/index.js => InfoBox.tsx} | 2 +- .../{Layout/index.js => Layout.tsx} | 2 +- .../{PostList/index.js => PostList.tsx} | 7 +- .../src/components/{index.js => index.ts} | 2 +- examples/react/nextjs/src/hooks/index.js | 1 - .../hooks/{usePosts/index.js => usePosts.ts} | 12 +- .../nextjs/src/pages/{_app.js => _app.tsx} | 3 +- .../pages/{client-only.js => client-only.tsx} | 2 +- .../nextjs/src/pages/{index.js => index.tsx} | 6 +- examples/react/nextjs/tsconfig.json | 19 ++ examples/react/offline/src/App.tsx | 2 +- examples/react/offline/src/api.ts | 1 + .../optimistic-updates-cache/next.config.js | 3 + .../optimistic-updates-cache/package.json | 2 - .../src/pages/api/{data.js => data.ts} | 10 +- .../src/pages/index.tsx | 11 +- .../optimistic-updates-ui/next.config.js | 3 + .../react/optimistic-updates-ui/package.json | 2 - .../src/pages/api/{data.js => data.ts} | 10 +- .../optimistic-updates-ui/src/pages/index.tsx | 5 +- examples/react/pagination/next-env.d.ts | 5 + examples/react/pagination/next.config.js | 3 + examples/react/pagination/package.json | 6 +- .../pages/api/{projects.js => projects.ts} | 5 +- .../src/pages/{index.js => index.tsx} | 11 +- examples/react/pagination/tsconfig.json | 19 ++ examples/react/playground/index.html | 2 +- examples/react/playground/package.json | 1 + .../playground/src/{index.jsx => index.tsx} | 51 +-- examples/react/playground/tsconfig.json | 24 ++ examples/react/playground/vite.config.ts | 6 + examples/react/prefetching/libs/fetch.js | 6 - examples/react/prefetching/next-env.d.ts | 5 + examples/react/prefetching/next.config.js | 3 + examples/react/prefetching/package.json | 6 +- .../pages/[user]/{[repo].js => [repo].tsx} | 24 +- .../src/pages/{_app.js => _app.tsx} | 3 +- .../react/prefetching/src/pages/api/data.js | 26 -- .../src/pages/{index.js => index.tsx} | 6 +- examples/react/prefetching/tsconfig.json | 19 ++ examples/react/rick-morty/index.html | 2 +- examples/react/rick-morty/package.json | 1 + .../src/App.jsx => rick-morty/src/App.tsx} | 4 +- .../rick-morty/src/{Layout.jsx => Layout.tsx} | 7 +- .../index.jsx => rick-morty/src/index.tsx} | 4 +- examples/react/rick-morty/tsconfig.json | 25 ++ examples/react/rick-morty/vite.config.ts | 6 + examples/react/shadow-dom/package.json | 9 +- examples/react/star-wars/index.html | 2 +- examples/react/star-wars/package.json | 1 + .../src/App.jsx => star-wars/src/App.tsx} | 8 +- .../star-wars/src/{Layout.jsx => Layout.tsx} | 9 +- .../src/index.jsx => star-wars/src/index.tsx} | 4 +- examples/react/star-wars/tsconfig.json | 25 ++ examples/react/star-wars/vite.config.ts | 6 + integrations/react-next-15/next.config.js | 3 + integrations/react-next-15/package.json | 5 +- integrations/react-next/next.config.js | 3 + integrations/react-next/package.json | 1 - pnpm-lock.yaml | 322 +++++++----------- 89 files changed, 589 insertions(+), 379 deletions(-) create mode 100644 examples/react/auto-refetching/next-env.d.ts rename examples/react/auto-refetching/src/pages/api/{data.js => data.ts} (67%) rename examples/react/auto-refetching/src/pages/{index.js => index.tsx} (93%) create mode 100644 examples/react/auto-refetching/tsconfig.json create mode 100644 examples/react/infinite-query-with-max-pages/next-env.d.ts rename examples/react/infinite-query-with-max-pages/src/pages/api/{projects.js => projects.ts} (78%) rename examples/react/infinite-query-with-max-pages/src/pages/{index.js => index.tsx} (100%) create mode 100644 examples/react/infinite-query-with-max-pages/tsconfig.json create mode 100644 examples/react/load-more-infinite-scroll/next-env.d.ts rename examples/react/load-more-infinite-scroll/src/pages/{about.js => about.tsx} (100%) rename examples/react/load-more-infinite-scroll/src/pages/api/{projects.js => projects.ts} (78%) rename examples/react/load-more-infinite-scroll/src/pages/{index.js => index.tsx} (91%) create mode 100644 examples/react/load-more-infinite-scroll/tsconfig.json create mode 100644 examples/react/nextjs/next-env.d.ts rename examples/react/nextjs/src/components/{Header/index.js => Header.tsx} (100%) rename examples/react/nextjs/src/components/{InfoBox/index.js => InfoBox.tsx} (83%) rename examples/react/nextjs/src/components/{Layout/index.js => Layout.tsx} (93%) rename examples/react/nextjs/src/components/{PostList/index.js => PostList.tsx} (89%) rename examples/react/nextjs/src/components/{index.js => index.ts} (100%) delete mode 100644 examples/react/nextjs/src/hooks/index.js rename examples/react/nextjs/src/hooks/{usePosts/index.js => usePosts.ts} (58%) rename examples/react/nextjs/src/pages/{_app.js => _app.tsx} (82%) rename examples/react/nextjs/src/pages/{client-only.js => client-only.tsx} (79%) rename examples/react/nextjs/src/pages/{index.js => index.tsx} (74%) create mode 100644 examples/react/nextjs/tsconfig.json rename examples/react/optimistic-updates-cache/src/pages/api/{data.js => data.ts} (66%) rename examples/react/optimistic-updates-ui/src/pages/api/{data.js => data.ts} (66%) create mode 100644 examples/react/pagination/next-env.d.ts rename examples/react/pagination/src/pages/api/{projects.js => projects.ts} (72%) rename examples/react/pagination/src/pages/{index.js => index.tsx} (95%) create mode 100644 examples/react/pagination/tsconfig.json rename examples/react/playground/src/{index.jsx => index.tsx} (91%) create mode 100644 examples/react/playground/tsconfig.json create mode 100644 examples/react/playground/vite.config.ts delete mode 100755 examples/react/prefetching/libs/fetch.js create mode 100644 examples/react/prefetching/next-env.d.ts rename examples/react/prefetching/src/pages/[user]/{[repo].js => [repo].tsx} (58%) rename examples/react/prefetching/src/pages/{_app.js => _app.tsx} (72%) delete mode 100644 examples/react/prefetching/src/pages/api/data.js rename examples/react/prefetching/src/pages/{index.js => index.tsx} (94%) create mode 100644 examples/react/prefetching/tsconfig.json rename examples/react/{star-wars/src/App.jsx => rick-morty/src/App.tsx} (97%) rename examples/react/rick-morty/src/{Layout.jsx => Layout.tsx} (91%) rename examples/react/{star-wars/src/index.jsx => rick-morty/src/index.tsx} (59%) create mode 100644 examples/react/rick-morty/tsconfig.json create mode 100644 examples/react/rick-morty/vite.config.ts rename examples/react/{rick-morty/src/App.jsx => star-wars/src/App.tsx} (90%) rename examples/react/star-wars/src/{Layout.jsx => Layout.tsx} (89%) rename examples/react/{rick-morty/src/index.jsx => star-wars/src/index.tsx} (59%) create mode 100644 examples/react/star-wars/tsconfig.json create mode 100644 examples/react/star-wars/vite.config.ts diff --git a/docs/config.json b/docs/config.json index 60cf48e8fe..d47c5bbb44 100644 --- a/docs/config.json +++ b/docs/config.json @@ -903,7 +903,7 @@ }, { "label": "Basic", - "to": "framework/solid/examples/basic-typescript" + "to": "framework/solid/examples/basic" }, { "label": "Basic w/ GraphQL-Request", diff --git a/examples/angular/infinite-query-with-max-pages/package.json b/examples/angular/infinite-query-with-max-pages/package.json index e47053a1ff..ac01ceb91b 100644 --- a/examples/angular/infinite-query-with-max-pages/package.json +++ b/examples/angular/infinite-query-with-max-pages/package.json @@ -1,13 +1,13 @@ { "name": "@tanstack/query-example-angular-infinite-query-with-max-pages", - "version": "0.0.0", + "private": true, + "type": "module", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development" }, - "private": true, "dependencies": { "@angular/common": "^17.3.10", "@angular/compiler": "^17.3.10", diff --git a/examples/react/auto-refetching/next-env.d.ts b/examples/react/auto-refetching/next-env.d.ts new file mode 100644 index 0000000000..4f11a03dc6 --- /dev/null +++ b/examples/react/auto-refetching/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/react/auto-refetching/next.config.js b/examples/react/auto-refetching/next.config.js index 4fd508c5f4..033754658c 100644 --- a/examples/react/auto-refetching/next.config.js +++ b/examples/react/auto-refetching/next.config.js @@ -5,6 +5,9 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, + typescript: { + ignoreBuildErrors: true, + }, } export default nextConfig diff --git a/examples/react/auto-refetching/package.json b/examples/react/auto-refetching/package.json index 3ec3ef35e0..3474926d4f 100644 --- a/examples/react/auto-refetching/package.json +++ b/examples/react/auto-refetching/package.json @@ -10,9 +10,13 @@ "dependencies": { "@tanstack/react-query": "^5.50.1", "@tanstack/react-query-devtools": "^5.50.1", - "isomorphic-unfetch": "4.0.2", "next": "^14.2.4", "react": "^18.2.0", "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "typescript": "5.3.3" } } diff --git a/examples/react/auto-refetching/src/pages/api/data.js b/examples/react/auto-refetching/src/pages/api/data.ts similarity index 67% rename from examples/react/auto-refetching/src/pages/api/data.js rename to examples/react/auto-refetching/src/pages/api/data.ts index 9c0cb35897..57faeb3916 100644 --- a/examples/react/auto-refetching/src/pages/api/data.js +++ b/examples/react/auto-refetching/src/pages/api/data.ts @@ -1,7 +1,12 @@ +import type { NextApiRequest, NextApiResponse } from 'next' + // an simple endpoint for getting current list let list = ['Item 1', 'Item 2', 'Item 3'] -export default async (req, res) => { +export default async ( + req: NextApiRequest, + res: NextApiResponse, +) => { if (req.query.add) { if (!list.includes(req.query.add)) { list.push(req.query.add) diff --git a/examples/react/auto-refetching/src/pages/index.js b/examples/react/auto-refetching/src/pages/index.tsx similarity index 93% rename from examples/react/auto-refetching/src/pages/index.js rename to examples/react/auto-refetching/src/pages/index.tsx index ace9bc343a..470a6e78fa 100644 --- a/examples/react/auto-refetching/src/pages/index.js +++ b/examples/react/auto-refetching/src/pages/index.tsx @@ -1,13 +1,11 @@ import React from 'react' -// - import { - useQuery, - useQueryClient, - useMutation, QueryClient, QueryClientProvider, + useMutation, + useQuery, + useQueryClient, } from '@tanstack/react-query' import { ReactQueryDevtools } from '@tanstack/react-query-devtools' @@ -28,7 +26,7 @@ function Example() { const { status, data, error, isFetching } = useQuery({ queryKey: ['todos'], - queryFn: async () => { + queryFn: async (): Promise> => { const response = await fetch('/api/data') return await response.json() }, @@ -37,7 +35,7 @@ function Example() { }) const addMutation = useMutation({ - mutationFn: (add) => fetch(`/api/data?add=${add}`), + mutationFn: (add: string) => fetch(`/api/data?add=${add}`), onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }), }) @@ -51,7 +49,7 @@ function Example() { return (
-

Auto Refetch with stale-time set to 1s)

+

Auto Refetch with stale-time set to {intervalMs}ms

This example is best experienced on your own machine, where you can open multiple tabs to the same localhost server and see your changes diff --git a/examples/react/auto-refetching/tsconfig.json b/examples/react/auto-refetching/tsconfig.json new file mode 100644 index 0000000000..9575d0eab5 --- /dev/null +++ b/examples/react/auto-refetching/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "Bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} diff --git a/examples/react/infinite-query-with-max-pages/next-env.d.ts b/examples/react/infinite-query-with-max-pages/next-env.d.ts new file mode 100644 index 0000000000..4f11a03dc6 --- /dev/null +++ b/examples/react/infinite-query-with-max-pages/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/react/infinite-query-with-max-pages/next.config.js b/examples/react/infinite-query-with-max-pages/next.config.js index 4fd508c5f4..033754658c 100644 --- a/examples/react/infinite-query-with-max-pages/next.config.js +++ b/examples/react/infinite-query-with-max-pages/next.config.js @@ -5,6 +5,9 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, + typescript: { + ignoreBuildErrors: true, + }, } export default nextConfig diff --git a/examples/react/infinite-query-with-max-pages/package.json b/examples/react/infinite-query-with-max-pages/package.json index 636bb35bd0..0da6802a24 100644 --- a/examples/react/infinite-query-with-max-pages/package.json +++ b/examples/react/infinite-query-with-max-pages/package.json @@ -10,10 +10,13 @@ "dependencies": { "@tanstack/react-query": "^5.50.1", "@tanstack/react-query-devtools": "^5.50.1", - "isomorphic-unfetch": "4.0.2", "next": "^14.2.4", "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-intersection-observer": "^8.34.0" + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "typescript": "5.3.3" } } diff --git a/examples/react/infinite-query-with-max-pages/src/pages/api/projects.js b/examples/react/infinite-query-with-max-pages/src/pages/api/projects.ts similarity index 78% rename from examples/react/infinite-query-with-max-pages/src/pages/api/projects.js rename to examples/react/infinite-query-with-max-pages/src/pages/api/projects.ts index a13fbee1aa..29b5228484 100644 --- a/examples/react/infinite-query-with-max-pages/src/pages/api/projects.js +++ b/examples/react/infinite-query-with-max-pages/src/pages/api/projects.ts @@ -1,5 +1,6 @@ -// an endpoint for getting projects data -export default (req, res) => { +import type { NextApiRequest, NextApiResponse } from 'next' + +export default (req: NextApiRequest, res: NextApiResponse) => { const cursor = parseInt(req.query.cursor) || 0 const pageSize = 4 diff --git a/examples/react/infinite-query-with-max-pages/src/pages/index.js b/examples/react/infinite-query-with-max-pages/src/pages/index.tsx similarity index 100% rename from examples/react/infinite-query-with-max-pages/src/pages/index.js rename to examples/react/infinite-query-with-max-pages/src/pages/index.tsx index 8df4c0e8d9..29fac3d44a 100644 --- a/examples/react/infinite-query-with-max-pages/src/pages/index.js +++ b/examples/react/infinite-query-with-max-pages/src/pages/index.tsx @@ -1,8 +1,8 @@ import React from 'react' import { - useInfiniteQuery, QueryClient, QueryClientProvider, + useInfiniteQuery, } from '@tanstack/react-query' import { ReactQueryDevtools } from '@tanstack/react-query-devtools' diff --git a/examples/react/infinite-query-with-max-pages/tsconfig.json b/examples/react/infinite-query-with-max-pages/tsconfig.json new file mode 100644 index 0000000000..9575d0eab5 --- /dev/null +++ b/examples/react/infinite-query-with-max-pages/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "Bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} diff --git a/examples/react/load-more-infinite-scroll/next-env.d.ts b/examples/react/load-more-infinite-scroll/next-env.d.ts new file mode 100644 index 0000000000..4f11a03dc6 --- /dev/null +++ b/examples/react/load-more-infinite-scroll/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/react/load-more-infinite-scroll/next.config.js b/examples/react/load-more-infinite-scroll/next.config.js index 4fd508c5f4..033754658c 100644 --- a/examples/react/load-more-infinite-scroll/next.config.js +++ b/examples/react/load-more-infinite-scroll/next.config.js @@ -5,6 +5,9 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, + typescript: { + ignoreBuildErrors: true, + }, } export default nextConfig diff --git a/examples/react/load-more-infinite-scroll/package.json b/examples/react/load-more-infinite-scroll/package.json index c35c1f54b9..219c55b20e 100644 --- a/examples/react/load-more-infinite-scroll/package.json +++ b/examples/react/load-more-infinite-scroll/package.json @@ -10,10 +10,14 @@ "dependencies": { "@tanstack/react-query": "^5.50.1", "@tanstack/react-query-devtools": "^5.50.1", - "isomorphic-unfetch": "4.0.2", "next": "^14.2.4", "react": "^18.2.0", "react-dom": "^18.2.0", "react-intersection-observer": "^8.34.0" + }, + "devDependencies": { + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "typescript": "5.3.3" } } diff --git a/examples/react/load-more-infinite-scroll/src/pages/about.js b/examples/react/load-more-infinite-scroll/src/pages/about.tsx similarity index 100% rename from examples/react/load-more-infinite-scroll/src/pages/about.js rename to examples/react/load-more-infinite-scroll/src/pages/about.tsx diff --git a/examples/react/load-more-infinite-scroll/src/pages/api/projects.js b/examples/react/load-more-infinite-scroll/src/pages/api/projects.ts similarity index 78% rename from examples/react/load-more-infinite-scroll/src/pages/api/projects.js rename to examples/react/load-more-infinite-scroll/src/pages/api/projects.ts index 03492c0a15..493a453a96 100644 --- a/examples/react/load-more-infinite-scroll/src/pages/api/projects.js +++ b/examples/react/load-more-infinite-scroll/src/pages/api/projects.ts @@ -1,5 +1,6 @@ -// an endpoint for getting projects data -export default (req, res) => { +import type { NextApiRequest, NextApiResponse } from 'next' + +export default (req: NextApiRequest, res: NextApiResponse) => { const cursor = parseInt(req.query.cursor) || 0 const pageSize = 5 diff --git a/examples/react/load-more-infinite-scroll/src/pages/index.js b/examples/react/load-more-infinite-scroll/src/pages/index.tsx similarity index 91% rename from examples/react/load-more-infinite-scroll/src/pages/index.js rename to examples/react/load-more-infinite-scroll/src/pages/index.tsx index b3b679be4e..9aa6742d15 100644 --- a/examples/react/load-more-infinite-scroll/src/pages/index.js +++ b/examples/react/load-more-infinite-scroll/src/pages/index.tsx @@ -34,13 +34,19 @@ function Example() { hasPreviousPage, } = useInfiniteQuery({ queryKey: ['projects'], - queryFn: async ({ pageParam }) => { + queryFn: async ({ + pageParam, + }): Promise<{ + data: Array<{ name: string; id: number }> + previousId: number + nextId: number + }> => { const response = await fetch(`/api/projects?cursor=${pageParam}`) return await response.json() }, initialPageParam: 0, - getPreviousPageParam: (firstPage) => firstPage.previousId ?? undefined, - getNextPageParam: (lastPage) => lastPage.nextId ?? undefined, + getPreviousPageParam: (firstPage) => firstPage.previousId, + getNextPageParam: (lastPage) => lastPage.nextId, }) React.useEffect(() => { diff --git a/examples/react/load-more-infinite-scroll/tsconfig.json b/examples/react/load-more-infinite-scroll/tsconfig.json new file mode 100644 index 0000000000..9575d0eab5 --- /dev/null +++ b/examples/react/load-more-infinite-scroll/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "Bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} diff --git a/examples/react/nextjs-app-prefetching/next.config.js b/examples/react/nextjs-app-prefetching/next.config.js index 4fd508c5f4..033754658c 100644 --- a/examples/react/nextjs-app-prefetching/next.config.js +++ b/examples/react/nextjs-app-prefetching/next.config.js @@ -5,6 +5,9 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, + typescript: { + ignoreBuildErrors: true, + }, } export default nextConfig diff --git a/examples/react/nextjs-app-prefetching/package.json b/examples/react/nextjs-app-prefetching/package.json index f3478e4ccb..d71d41a088 100644 --- a/examples/react/nextjs-app-prefetching/package.json +++ b/examples/react/nextjs-app-prefetching/package.json @@ -12,11 +12,10 @@ "@tanstack/react-query": "^5.50.1", "@tanstack/react-query-devtools": "^5.50.1", "next": "^15.0.0-rc.0", - "react": "^19.0.0-rc-4c2e457c7c-20240522", - "react-dom": "^19.0.0-rc-4c2e457c7c-20240522" + "react": "19.0.0-rc-4c2e457c7c-20240522", + "react-dom": "19.0.0-rc-4c2e457c7c-20240522" }, "devDependencies": { - "@types/node": "^20.12.12", "@types/react": "npm:types-react@rc", "@types/react-dom": "npm:types-react-dom@rc", "typescript": "5.3.3" diff --git a/examples/react/nextjs-suspense-streaming/next.config.js b/examples/react/nextjs-suspense-streaming/next.config.js index 9b538eb739..591cd313c3 100644 --- a/examples/react/nextjs-suspense-streaming/next.config.js +++ b/examples/react/nextjs-suspense-streaming/next.config.js @@ -5,6 +5,9 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, + typescript: { + ignoreBuildErrors: true, + }, webpack: (config) => { if (config.name === 'server') config.optimization.concatenateModules = false diff --git a/examples/react/nextjs-suspense-streaming/package.json b/examples/react/nextjs-suspense-streaming/package.json index f282f6a039..958f9b4232 100644 --- a/examples/react/nextjs-suspense-streaming/package.json +++ b/examples/react/nextjs-suspense-streaming/package.json @@ -14,11 +14,9 @@ "@tanstack/react-query-next-experimental": "^5.50.1", "next": "^14.2.4", "react": "^18.2.0", - "react-dom": "^18.2.0", - "superjson": "^2.2.1" + "react-dom": "^18.2.0" }, "devDependencies": { - "@types/node": "^20.12.12", "@types/react": "^18.2.79", "typescript": "5.3.3" } diff --git a/examples/react/nextjs/next-env.d.ts b/examples/react/nextjs/next-env.d.ts new file mode 100644 index 0000000000..4f11a03dc6 --- /dev/null +++ b/examples/react/nextjs/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/react/nextjs/next.config.js b/examples/react/nextjs/next.config.js index 4fd508c5f4..033754658c 100644 --- a/examples/react/nextjs/next.config.js +++ b/examples/react/nextjs/next.config.js @@ -5,6 +5,9 @@ const nextConfig = { eslint: { ignoreDuringBuilds: true, }, + typescript: { + ignoreBuildErrors: true, + }, } export default nextConfig diff --git a/examples/react/nextjs/package.json b/examples/react/nextjs/package.json index 6c40ed726f..4388f88cc1 100644 --- a/examples/react/nextjs/package.json +++ b/examples/react/nextjs/package.json @@ -12,8 +12,11 @@ "@tanstack/react-query-devtools": "^5.50.1", "next": "^14.2.4", "react": "^18.2.0", - "react-dom": "^18.2.0", - "resolve-from": "^5.0.0", - "web-streams-polyfill": "^4.0.0" + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "typescript": "5.3.3" } } diff --git a/examples/react/nextjs/src/components/Header/index.js b/examples/react/nextjs/src/components/Header.tsx similarity index 100% rename from examples/react/nextjs/src/components/Header/index.js rename to examples/react/nextjs/src/components/Header.tsx diff --git a/examples/react/nextjs/src/components/InfoBox/index.js b/examples/react/nextjs/src/components/InfoBox.tsx similarity index 83% rename from examples/react/nextjs/src/components/InfoBox/index.js rename to examples/react/nextjs/src/components/InfoBox.tsx index b0ff42f7d3..4bc1ecbbea 100644 --- a/examples/react/nextjs/src/components/InfoBox/index.js +++ b/examples/react/nextjs/src/components/InfoBox.tsx @@ -1,6 +1,6 @@ import React from 'react' -const InfoBox = ({ children }) => ( +const InfoBox = ({ children }: { children: React.ReactNode }) => (