Skip to content

Commit

Permalink
Merge branch 'canary' into update-with-styled-components-example
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam-Phillemon9493 authored Oct 4, 2024
2 parents 566c392 + 8894bed commit 4b87c8c
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "15.0.0-canary.177"
"version": "15.0.0-canary.178"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "15.0.0-canary.177",
"version": "15.0.0-canary.178",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "15.0.0-canary.177",
"version": "15.0.0-canary.178",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { cookies } from 'next/headers'

export type Cookie = ReturnType<typeof cookies>
export function foo(c: ReturnType<typeof cookies>) {
return c
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { cookies } from 'next/headers'

export type Cookie = Awaited<ReturnType<typeof cookies>>
export function foo(c: Awaited<ReturnType<typeof cookies>>) {
return c
}

Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,42 @@ export function transformDynamicAPI(
}
}
})

// Handle type usage of async API, e.g. `type Cookie = ReturnType<typeof cookies>`
// convert it to `type Cookie = Awaited<ReturnType<typeof cookies>>`
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<typeof cookies> with Awaited<ReturnType<typeof cookies>>
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)
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "15.0.0-canary.177",
"version": "15.0.0-canary.178",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/third-parties/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
},
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4b87c8c

Please sign in to comment.