-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
2,039 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-01.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { cookies } from 'next/headers' | ||
|
||
export async function MyComponent() { | ||
const name = cookies().get('name') | ||
callback(name) | ||
} | ||
|
||
function callback(name: any) { | ||
console.log(name) | ||
} |
10 changes: 10 additions & 0 deletions
10
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-01.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { cookies } from 'next/headers' | ||
|
||
export async function MyComponent() { | ||
const name = (await cookies()).get('name') | ||
callback(name) | ||
} | ||
|
||
function callback(name: any) { | ||
console.log(name) | ||
} |
5 changes: 5 additions & 0 deletions
5
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-02.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { draftMode } from 'next/headers' | ||
|
||
export async function MyComponent() { | ||
draftMode().enable() | ||
} |
5 changes: 5 additions & 0 deletions
5
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-02.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { draftMode } from 'next/headers' | ||
|
||
export async function MyComponent() { | ||
(await draftMode()).enable() | ||
} |
6 changes: 6 additions & 0 deletions
6
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-03.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// If it's sync default export, convert to async and await the function call | ||
import { draftMode } from 'next/headers' | ||
|
||
export default function MyComponent() { | ||
draftMode().enable() | ||
} |
6 changes: 6 additions & 0 deletions
6
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-03.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// If it's sync default export, convert to async and await the function call | ||
import { draftMode } from 'next/headers' | ||
|
||
export default async function MyComponent() { | ||
(await draftMode()).enable() | ||
} |
9 changes: 9 additions & 0 deletions
9
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-04.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { draftMode } from 'next/headers' | ||
|
||
export default async function MyComponent() { | ||
draftMode().enable() | ||
} | ||
|
||
export async function MyComponent2() { | ||
draftMode().enable() | ||
} |
9 changes: 9 additions & 0 deletions
9
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-04.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { draftMode } from 'next/headers' | ||
|
||
export default async function MyComponent() { | ||
(await draftMode()).enable() | ||
} | ||
|
||
export async function MyComponent2() { | ||
(await draftMode()).enable() | ||
} |
9 changes: 9 additions & 0 deletions
9
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-05.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { draftMode } from 'next/headers' | ||
|
||
export function MyComponent2() { | ||
draftMode().enable() | ||
} | ||
|
||
export function useDraftModeEnabled() { | ||
draftMode().enable() | ||
} |
10 changes: 10 additions & 0 deletions
10
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-05.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { use } from "react"; | ||
import { draftMode, type UnsafeUnwrappedDraftMode } from 'next/headers'; | ||
|
||
export function MyComponent2() { | ||
(draftMode() as unknown as UnsafeUnwrappedDraftMode).enable() | ||
} | ||
|
||
export function useDraftModeEnabled() { | ||
use(draftMode()).enable() | ||
} |
6 changes: 6 additions & 0 deletions
6
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-06.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react' | ||
import { draftMode } from 'next/headers' | ||
|
||
export default function Page() { | ||
return <button disabled={draftMode().isEnabled}>Enable Draft Mode</button> | ||
} |
7 changes: 7 additions & 0 deletions
7
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-06.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
import { draftMode } from 'next/headers' | ||
|
||
export default async function Page() { | ||
return <button disabled={(await draftMode()).isEnabled}>Enable Draft Mode</button>; | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-07.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Already imported the type | ||
import { draftMode, type UnsafeUnwrappedDraftMode } from 'next/headers' | ||
|
||
export function MyComponent2() { | ||
draftMode().enable() | ||
} |
6 changes: 6 additions & 0 deletions
6
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-07.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Already imported the type | ||
import { draftMode, type UnsafeUnwrappedDraftMode } from 'next/headers' | ||
|
||
export function MyComponent2() { | ||
(draftMode() as unknown as UnsafeUnwrappedDraftMode).enable() | ||
} |
5 changes: 5 additions & 0 deletions
5
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-08.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { headers } from 'next/headers' | ||
|
||
export function GET(): Response { | ||
headers() | ||
} |
5 changes: 5 additions & 0 deletions
5
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-08.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { headers } from 'next/headers' | ||
|
||
export async function GET(): Promise<Response> { | ||
await headers() | ||
} |
13 changes: 13 additions & 0 deletions
13
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-09.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function Page({ | ||
params: { slug }, | ||
searchParams: { search }, | ||
}: { | ||
params: { slug: string } | ||
searchParams: any | ||
}): JSX.Element { | ||
// Access to the destructed properties | ||
slug | ||
search | ||
|
||
return <div>Page</div> | ||
} |
24 changes: 24 additions & 0 deletions
24
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-09.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export default async function Page( | ||
props: { | ||
params: Promise<{ slug: string }> | ||
searchParams: Promise<any> | ||
} | ||
): Promise<JSX.Element> { | ||
const searchParams = await props.searchParams; | ||
|
||
const { | ||
search | ||
} = searchParams; | ||
|
||
const params = await props.params; | ||
|
||
const { | ||
slug | ||
} = params; | ||
|
||
// Access to the destructed properties | ||
slug | ||
search | ||
|
||
return <div>Page</div> | ||
} |
13 changes: 13 additions & 0 deletions
13
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-10.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { headers } from 'next/headers' | ||
|
||
export function MyComp() { | ||
return headers() | ||
} | ||
|
||
export function MyComp2() { | ||
return headers() | ||
} | ||
|
||
export function MyComp3() { | ||
return headers() | ||
} |
13 changes: 13 additions & 0 deletions
13
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-10.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { headers, type UnsafeUnwrappedHeaders } from 'next/headers'; | ||
|
||
export function MyComp() { | ||
return (headers() as unknown as UnsafeUnwrappedHeaders); | ||
} | ||
|
||
export function MyComp2() { | ||
return (headers() as unknown as UnsafeUnwrappedHeaders); | ||
} | ||
|
||
export function MyComp3() { | ||
return (headers() as unknown as UnsafeUnwrappedHeaders); | ||
} |
9 changes: 9 additions & 0 deletions
9
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-11.input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { headers } from 'next/headers' | ||
|
||
export function MyComp() { | ||
headers() | ||
} | ||
|
||
export function generateContentfulMetadata() { | ||
headers() | ||
} |
10 changes: 10 additions & 0 deletions
10
...d/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-11.output.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { headers, type UnsafeUnwrappedHeaders } from 'next/headers'; | ||
|
||
export function MyComp() { | ||
(headers() as unknown as UnsafeUnwrappedHeaders) | ||
} | ||
|
||
export function generateContentfulMetadata() { | ||
(headers() as unknown as UnsafeUnwrappedHeaders) | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
...mod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-12.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
async function MyComponent() { | ||
callSomething(cookies()); | ||
} |
5 changes: 5 additions & 0 deletions
5
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-12.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
async function MyComponent() { | ||
callSomething(await cookies()); | ||
} |
5 changes: 5 additions & 0 deletions
5
...mod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-13.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { headers } from "next/headers"; | ||
|
||
async function MyComponent() { | ||
callSomething(headers()); | ||
} |
5 changes: 5 additions & 0 deletions
5
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-13.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { headers } from "next/headers"; | ||
|
||
async function MyComponent() { | ||
callSomething(await headers()); | ||
} |
5 changes: 5 additions & 0 deletions
5
...mod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-14.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
export default async function Page() { | ||
callSomething(cookies()); | ||
} |
5 changes: 5 additions & 0 deletions
5
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-14.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
export default async function Page() { | ||
callSomething(await cookies()); | ||
} |
7 changes: 7 additions & 0 deletions
7
...mod/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-15.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
async function MyComponent() { | ||
function asyncFunction() { | ||
callSomething(cookies()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...od/transforms/__testfixtures__/next-async-request-api-dynamic-apis/async-api-15.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
async function MyComponent() { | ||
function asyncFunction() { | ||
callSomething(/* TODO: please manually await this call, codemod cannot transform due to undetermined async scope */ | ||
cookies()); | ||
} | ||
} |
Oops, something went wrong.