airbnb / ts-migrate

A tool to help migrate JavaScript code quickly and conveniently to TypeScript
MIT License
5.42k stars 218 forks source link

Broken code gen in strict mode with functions on object attributes #182

Open kwojcik opened 2 years ago

kwojcik commented 2 years ago

Forgive my poor issue title because I don't know the exact issue, but I've got a perfect minimal repro for you https://github.com/kwojcik/ts-migrate-bug.

The generated code has extra })'s and breaks.

kwojcik commented 2 years ago
diff --git a/src/Property.js b/src/Property.js
index 7aba662..12cf253 100644
--- a/src/Property.js
+++ b/src/Property.js
@@ -7,8 +7,9 @@ export default class Property {
   overview() {
     return flatten(this.foos.map(foo =>
       Object.entries(groupBy(foo.foo, 'bar')).map(() => {
+        const { fooType } = foo;
         return {
-          name: `${foo.fooType}`,
+          name: `${fooType}`,
         };
       })
     ));

this change to the src fixes it

oltodo commented 1 year ago

I met the same issue