Skip to content

Commit

Permalink
Fix for codemod that removes types from the blitz config file (#3759)
Browse files Browse the repository at this point in the history
* check if typeAnnotation when trying to remove types during creating the next config file with codemod
  • Loading branch information
Dillon Raphael authored Aug 26, 2022
1 parent a84b8de commit 43e65cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-kangaroos-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blitzjs/codemod": patch
---

Remove TypeScript type annotations from `next.config.js` (a JavaScript file) in the `upgrade-legacy` codemod.
8 changes: 6 additions & 2 deletions packages/codemod/src/upgrade-legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 43e65cf

Please sign in to comment.