Skip to content

Commit

Permalink
codemod: fix missing route transform (#70959)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored and kdy1 committed Oct 10, 2024
1 parent 8ced6ba commit f3e1e0e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function GET(req, { params }) {
f1(params)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export async function GET(req, props) {
const params = await props.params;
f1(params)
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ describe('next-async-request-api - dynamic-props', () => {

// Override test fixture input filename with `page.tsx` to always match the expected output,
// otherwise fallback to the original filename.
const overrideFilename = /[\\/]origin-name-/.test(inputPath) ? inputPath : 'page.tsx'
const overrideFilename = /[\\/]origin-name-\d{2}-/.test(inputPath)
// extract the <name> from `origin-name-<name>-<number>.input.js`
? inputPath
.replace(/origin-name-(\d{2})-/, '')
.replace(/\.input\./, '.')
: 'page.tsx'

it(`transforms correctly ${prefix}`, () => {
runInlineTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function applyUseAndRenameAccessedProp(
return modified
}

const MATCHED_FILE_PATTERNS = /([\\/]|^)(page|layout)\.(t|j)sx?$/
const MATCHED_FILE_PATTERNS = /([\\/]|^)(page|layout|route)\.(t|j)sx?$/

function modifyTypes(
paramTypeAnnotation: any,
Expand Down

0 comments on commit f3e1e0e

Please sign in to comment.