diff --git a/.changeset/fair-kangaroos-clean.md b/.changeset/fair-kangaroos-clean.md new file mode 100644 index 0000000000..654b1f2f67 --- /dev/null +++ b/.changeset/fair-kangaroos-clean.md @@ -0,0 +1,5 @@ +--- +"@blitzjs/codemod": patch +--- + +Remove TypeScript type annotations from `next.config.js` (a JavaScript file) in the `upgrade-legacy` codemod. diff --git a/packages/codemod/src/upgrade-legacy.ts b/packages/codemod/src/upgrade-legacy.ts index 9844158424..88f409ec72 100644 --- a/packages/codemod/src/upgrade-legacy.ts +++ b/packages/codemod/src/upgrade-legacy.ts @@ -70,8 +70,12 @@ const upgradeLegacy = async () => { // Remove all typescript stuff let findTypes = program.find(j.TSType, (node) => node) - if (findTypes) { - findTypes.forEach((t) => j(t.parentPath).remove()) + if (findTypes.length) { + findTypes.forEach((t) => { + if (t.name === "typeAnnotation") { + j(t.parentPath).remove() + } + }) } let withBlitz = j.objectProperty(j.identifier("withBlitz"), j.identifier("withBlitz"))