Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: TypeScript annotation affects output #16377

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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