diff --git a/lerna.json b/lerna.json index 63e98d6a1b728..e6496bf8d6d28 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "15.0.0-canary.177" + "version": "15.0.0-canary.178" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index bc2ca3cad0c1a..e4bf4964eb866 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 03a486094a9dc..0d9323e08bfcf 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "description": "ESLint configuration used by Next.js.", "main": "index.js", "license": "MIT", @@ -10,7 +10,7 @@ }, "homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config", "dependencies": { - "@next/eslint-plugin-next": "15.0.0-canary.177", + "@next/eslint-plugin-next": "15.0.0-canary.178", "@rushstack/eslint-patch": "^1.3.3", "@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 07113c24513d7..7c0d01e8f5713 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "description": "ESLint plugin for Next.js.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index 68896a7359655..afa6098711d0c 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,7 +1,7 @@ { "name": "@next/font", "private": true, - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index e7cabfd8e9178..491ce81f50a79 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 51b0bf84d356f..aaa07f8c13cff 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-23.input.tsx b/packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-23.input.tsx new file mode 100644 index 0000000000000..82796fa7ecf09 --- /dev/null +++ b/packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-23.input.tsx @@ -0,0 +1,6 @@ +import { cookies } from 'next/headers' + +export type Cookie = ReturnType +export function foo(c: ReturnType) { + return c +} diff --git a/packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-23.output.tsx b/packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-23.output.tsx new file mode 100644 index 0000000000000..b77bd963c1c11 --- /dev/null +++ b/packages/next-codemod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-23.output.tsx @@ -0,0 +1,7 @@ +import { cookies } from 'next/headers' + +export type Cookie = Awaited> +export function foo(c: Awaited>) { + return c +} + diff --git a/packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-api.ts b/packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-api.ts index 64c910fc5402b..9c1ad6feab2cd 100644 --- a/packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-api.ts +++ b/packages/next-codemod/transforms/lib/async-request-api/next-async-dynamic-api.ts @@ -205,6 +205,42 @@ export function transformDynamicAPI( } } }) + + // Handle type usage of async API, e.g. `type Cookie = ReturnType` + // convert it to `type Cookie = Awaited>` + root + .find(j.TSTypeReference, { + typeName: { + type: 'Identifier', + name: 'ReturnType', + }, + }) + .forEach((path) => { + const typeParam = path.node.typeParameters?.params[0] + + // Check if the ReturnType is for 'cookies' + if ( + typeParam && + j.TSTypeQuery.check(typeParam) && + j.Identifier.check(typeParam.exprName) && + typeParam.exprName.name === asyncRequestApiName + ) { + // Replace ReturnType with Awaited> + const awaitedTypeReference = j.tsTypeReference( + j.identifier('Awaited'), + j.tsTypeParameterInstantiation([ + j.tsTypeReference( + j.identifier('ReturnType'), + j.tsTypeParameterInstantiation([typeParam]) + ), + ]) + ) + + j(path).replaceWith(awaitedTypeReference) + + modified = true + } + }) } const isClientComponent = determineClientDirective(root, j) diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 04cd5692c0409..c8e90b6237d95 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 57f863ce69b47..7975b4c0554bf 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 33b8323206b3d..c7734267a3501 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 2d7b80389af03..35ab237abea9b 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index af227f1ae802b..2cc73f7efe83d 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 58d1e7eb0dcda..d552ba71435ec 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index d0552565830e6..eab33dd9618d7 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -95,7 +95,7 @@ ] }, "dependencies": { - "@next/env": "15.0.0-canary.177", + "@next/env": "15.0.0-canary.178", "@swc/counter": "0.1.3", "@swc/helpers": "0.5.13", "busboy": "1.6.0", @@ -159,11 +159,11 @@ "@jest/types": "29.5.0", "@mswjs/interceptors": "0.23.0", "@napi-rs/triples": "1.2.0", - "@next/font": "15.0.0-canary.177", - "@next/polyfill-module": "15.0.0-canary.177", - "@next/polyfill-nomodule": "15.0.0-canary.177", - "@next/react-refresh-utils": "15.0.0-canary.177", - "@next/swc": "15.0.0-canary.177", + "@next/font": "15.0.0-canary.178", + "@next/polyfill-module": "15.0.0-canary.178", + "@next/polyfill-nomodule": "15.0.0-canary.178", + "@next/react-refresh-utils": "15.0.0-canary.178", + "@next/swc": "15.0.0-canary.178", "@opentelemetry/api": "1.6.0", "@playwright/test": "1.41.2", "@swc/core": "1.7.0-nightly-20240714.1", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index ef5baa6904567..b39a7fbf37f75 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/packages/third-parties/package.json b/packages/third-parties/package.json index 257b5e8815b9c..39e7714b348c6 100644 --- a/packages/third-parties/package.json +++ b/packages/third-parties/package.json @@ -1,6 +1,6 @@ { "name": "@next/third-parties", - "version": "15.0.0-canary.177", + "version": "15.0.0-canary.178", "repository": { "url": "vercel/next.js", "directory": "packages/third-parties" @@ -26,7 +26,7 @@ "third-party-capital": "1.0.20" }, "devDependencies": { - "next": "15.0.0-canary.177", + "next": "15.0.0-canary.178", "outdent": "0.8.0", "prettier": "2.5.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0c2b902067842..fe51b9e4b0b28 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -792,7 +792,7 @@ importers: packages/eslint-config-next: dependencies: '@next/eslint-plugin-next': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../eslint-plugin-next '@rushstack/eslint-patch': specifier: ^1.3.3 @@ -853,7 +853,7 @@ importers: packages/next: dependencies: '@next/env': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../next-env '@swc/counter': specifier: 0.1.3 @@ -863,7 +863,7 @@ importers: version: 0.5.13 babel-plugin-react-compiler: specifier: '*' - version: 0.0.0-experimental-b4db8c3-20241001 + version: 0.0.0-experimental-27e0f40-20241002 busboy: specifier: 1.6.0 version: 1.6.0 @@ -981,19 +981,19 @@ importers: specifier: 1.2.0 version: 1.2.0 '@next/font': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../font '@next/polyfill-module': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../next-polyfill-module '@next/polyfill-nomodule': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../next-polyfill-nomodule '@next/react-refresh-utils': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../react-refresh-utils '@next/swc': - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../next-swc '@opentelemetry/api': specifier: 1.6.0 @@ -1612,7 +1612,7 @@ importers: version: 1.0.20 devDependencies: next: - specifier: 15.0.0-canary.177 + specifier: 15.0.0-canary.178 version: link:../next outdent: specifier: 0.8.0 @@ -5953,8 +5953,8 @@ packages: peerDependencies: '@babel/core': 7.22.5 - babel-plugin-react-compiler@0.0.0-experimental-b4db8c3-20241001: - resolution: {integrity: sha512-2qiuysJU65kKm4CznEMxpjvGV4FOlreXlpJwfJrOIqVxyQYL156614vzXFzuPObCsiwJrA5agXoAI9EP8zuvBw==} + babel-plugin-react-compiler@0.0.0-experimental-27e0f40-20241002: + resolution: {integrity: sha512-hMOwSqoI0gxyjgGVhsMqPsVV4bjCqJ2WTUFsQyrk+KAkDqK/o7Th9XRl/xhVApPbE4VzQeiutC60rbBGqNebHQ==} babel-plugin-react-compiler@0.0.0-experimental-c23de8d-20240515: resolution: {integrity: sha512-0XN2gmpT55QtAz5n7d5g91y1AuO9tRhWBaLgCRyc4ExHrlr7+LfxW+YTb3mOwxngkkiggwM8HyYsaEK9MqhnlQ==} @@ -20682,7 +20682,7 @@ snapshots: - supports-color optional: true - babel-plugin-react-compiler@0.0.0-experimental-b4db8c3-20241001: + babel-plugin-react-compiler@0.0.0-experimental-27e0f40-20241002: dependencies: '@babel/generator': 7.2.0 '@babel/types': 7.22.5