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(es/config): respect the value of assumptions #7065

Merged
merged 4 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/swc/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ impl Options {
// We do this before creating custom passes, so custom passses can use the
// variable management system based on the syntax contexts.
if syntax.typescript() {
assumptions.set_class_methods = !transform.use_define_for_class_fields.into_bool();
assumptions.set_class_methods |= !transform.use_define_for_class_fields.into_bool();
}

assumptions.set_public_class_fields = !transform.use_define_for_class_fields.into_bool();
assumptions.set_public_class_fields |= !transform.use_define_for_class_fields.into_bool();

program.visit_mut_with(&mut resolver(
unresolved_mark,
Expand Down
4 changes: 0 additions & 4 deletions crates/swc/tests/fixture/issues-1xxx/1278/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
const _defineProperty = require("@swc/helpers/lib/_define_property.js").default;
const _tsDecorate = require("@swc/helpers/lib/_ts_decorate.js").default;
const _tsMetadata = require("@swc/helpers/lib/_ts_metadata.js").default;
function MyDecorator(klass) {
Expand All @@ -12,9 +11,6 @@ function MyDecorator(klass) {
};
}
class MyClass {
constructor(){
_defineProperty(this, "prop", void 0);
}
}
_tsDecorate([
MyDecorator(MyClass),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _define_property from "@swc/helpers/src/_define_property.mjs";
var _ClassB;
var ClassA = function ClassA() {
"use strict";
Expand All @@ -11,4 +10,6 @@ module.exports = (_ClassB = /*#__PURE__*/ function() {
this.bb = new ClassB.MyA();
};
return ClassB;
}(), _define_property(_ClassB, "MyA", ClassA), _ClassB);
}(), function() {
_ClassB.MyA = ClassA;
}(), _ClassB);
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var t;
import r from "@swc/helpers/src/_define_property.mjs";
module.exports = (r(t = function() {
module.exports = ((t = function() {
"use strict";
function t() {}
return t.prototype.it = function() {
this.bb = new t.MyA();
}, t;
}(), "MyA", function() {}), t);
}()).MyA = function() {}, t);
9 changes: 2 additions & 7 deletions crates/swc/tests/fixture/issues-2xxx/2216/output/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import _create_class from "@swc/helpers/src/_create_class.mjs";
export var ATestForSwc = /*#__PURE__*/ function() {
"use strict";
function ATestForSwc() {}
_create_class(ATestForSwc, [
{
key: "testMethod",
value: function testMethod() {}
}
]);
var _proto = ATestForSwc.prototype;
_proto.testMethod = function testMethod() {};
return ATestForSwc;
}();