Skip to content

Commit

Permalink
fix: TypeScript annotation affects output (#16377)
Browse files Browse the repository at this point in the history
skip TSTypeAnnotation
  • Loading branch information
liuxingbaoyu committed Apr 24, 2024
1 parent ee48754 commit e779cad
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Database {
transaction(
// If the type annotation here contains the *name of the method*
// then it changes how the method is compiled. Rename `transaction`
// below and see how the output changes.
callback: (transaction: Transaction) => unknown,
) {
return this.table.transaction(
(x) => callback(new DaoTransaction(x)),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["transform-classes", "transform-typescript"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let Database = /*#__PURE__*/function () {
"use strict";

function Database() {
babelHelpers.classCallCheck(this, Database);
}
return babelHelpers.createClass(Database, [{
key: "transaction",
value: function transaction(
// If the type annotation here contains the *name of the method*
// then it changes how the method is compiled. Rename `transaction`
// below and see how the output changes.
callback) {
return this.table.transaction(x => callback(new DaoTransaction(x)));
}
}]);
}();
3 changes: 3 additions & 0 deletions packages/babel-traverse/src/scope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ const collectorVisitor: Visitor<CollectVisitorState> = {
path.scope.registerBinding("local", path);
}
},
TSTypeAnnotation(path) {
path.skip();
},
};

let uid = 0;
Expand Down

0 comments on commit e779cad

Please sign in to comment.