-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transformer/class-properties): transform private in expression
- Loading branch information
Showing
10 changed files
with
150 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...abel-plugin-transform-private-property-in-object/test/fixtures/private/accessor/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var _Foo_brand = new WeakSet(); | ||
class Foo { | ||
constructor() { | ||
babelHelpers.classPrivateMethodInitSpec(this, _Foo_brand); | ||
} | ||
test(other) { | ||
return _Foo_brand.has(babelHelpers.checkInRHS(other)); | ||
} | ||
} | ||
function _get_foo() {} |
6 changes: 6 additions & 0 deletions
6
...ugin-transform-private-property-in-object/test/fixtures/private/static-accessor/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Foo { | ||
test(other) { | ||
return babelHelpers.checkInRHS(other) === Foo; | ||
} | ||
} | ||
function _get_foo() {} |
10 changes: 10 additions & 0 deletions
10
...in-transform-private-property-in-object/test/fixtures/to-native-fields/accessor/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var _Foo_brand = new WeakSet(); | ||
class Foo { | ||
constructor() { | ||
babelHelpers.classPrivateMethodInitSpec(this, _Foo_brand); | ||
} | ||
test(other) { | ||
return _Foo_brand.has(babelHelpers.checkInRHS(other)); | ||
} | ||
} | ||
function _get_foo() {} |
20 changes: 20 additions & 0 deletions
20
...ate-property-in-object/test/fixtures/to-native-fields/half-constructed-instance/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var _F_brand = new WeakSet(); | ||
var _x = new WeakMap(); | ||
var _y = new WeakMap(); | ||
class F { | ||
constructor() { | ||
babelHelpers.classPrivateMethodInitSpec(this, _F_brand); | ||
babelHelpers.classPrivateFieldInitSpec(this, _x, 0); | ||
babelHelpers.classPrivateFieldInitSpec(this, _y, (() => { | ||
throw "error"; | ||
})()); | ||
} | ||
m() { | ||
_F_brand.has(babelHelpers.checkInRHS(this)); | ||
_x.has(babelHelpers.checkInRHS(this)); | ||
_y.has(babelHelpers.checkInRHS(this)); | ||
_F_brand.has(babelHelpers.checkInRHS(this)); | ||
} | ||
} | ||
function _get_w() {} | ||
function _z() {} |
6 changes: 6 additions & 0 deletions
6
...sform-private-property-in-object/test/fixtures/to-native-fields/static-accessor/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Foo { | ||
test(other) { | ||
return babelHelpers.checkInRHS(other) === Foo; | ||
} | ||
} | ||
function _get_foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ commit: 54a8389f | |
|
||
node: v22.12.0 | ||
|
||
Passed: 283 of 374 (75.67%) | ||
Passed: 291 of 374 (77.81%) | ||
|
||
Failures: | ||
|
||
|
@@ -78,9 +78,6 @@ AssertionError: expected '_Class' to be 'Foo' // Object.is equality | |
AssertionError: expected '_Class' to be 'Foo' // Object.is equality | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-properties-test-fixtures-public-static-infer-name-exec.test.js:9:19 | ||
|
||
./fixtures/babel/babel-plugin-transform-class-static-block-test-fixtures-integration-loose-private-in-exec.test.js | ||
Private field '#bar' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-class-static-block-test-fixtures-integration-loose-private-methods-access-exec.test.js | ||
TypeError: attempted to use private field on non-instance | ||
at _classPrivateFieldBase (./node_modules/.pnpm/@babel[email protected]/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js:2:44) | ||
|
@@ -91,9 +88,6 @@ TypeError: attempted to use private field on non-instance | |
AssertionError: expected [Function Base] to be undefined // Object.is equality | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-class-static-block-test-fixtures-integration-new-target-exec.test.js:10:29 | ||
|
||
./fixtures/babel/babel-plugin-transform-class-static-block-test-fixtures-integration-private-in-exec.test.js | ||
Private field '#bar' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-assumption-noDocumentAll-parenthesized-expression-member-call-exec.test.js | ||
TypeError: Cannot read properties of undefined (reading 'x') | ||
at m (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-assumption-noDocumentAll-parenthesized-expression-member-call-exec.test.js:10:16) | ||
|
@@ -415,40 +409,32 @@ TypeError: "#privateStaticFieldValue" is write-only | |
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js:14:12 | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-assumption-privateFieldsAsProperties-method-exec.test.js | ||
Private field '#foo' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-assumption-privateFieldsAsProperties-rhs-not-object-exec.test.js | ||
Private field '#p' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-assumption-privateFieldsAsSymbols-method-exec.test.js | ||
Private field '#foo' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-assumption-privateFieldsAsSymbols-rhs-not-object-exec.test.js | ||
Private field '#p' must be declared in an enclosing class | ||
ReferenceError: _Foo_brand is not defined | ||
at new Foo (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-assumption-privateFieldsAsProperties-method-exec.test.js:8:38) | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-assumption-privateFieldsAsProperties-method-exec.test.js:19:13 | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-loose-rhs-not-object-exec.test.js | ||
Private field '#p' must be declared in an enclosing class | ||
AssertionError: expected [Function] to throw error including 'right-hand side of \'in\' should be a…' but got '_Class_brand is not defined' | ||
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest[email protected]/node_modules/@vitest/expect/dist/index.js:1438:21) | ||
at Proxy.<anonymous> (./node_modules/.pnpm/@vitest[email protected]/node_modules/@vitest/expect/dist/index.js:923:17) | ||
at Proxy.methodWrapper (./node_modules/.pnpm/[email protected]/node_modules/chai/chai.js:1610:25) | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-loose-rhs-not-object-exec.test.js:176:5 | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-loose-static-shadow-exec.test.js | ||
Private field '#x' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-rhs-not-object-exec.test.js | ||
Private field '#p' must be declared in an enclosing class | ||
AssertionError: expected 2 to be 5 // Object.is equality | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-loose-static-shadow-exec.test.js:18:25 | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-static-shadow-exec.test.js | ||
Private field '#x' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-to-native-fields-half-constructed-instance-exec.test.js | ||
Private field '#w' must be declared in an enclosing class | ||
AssertionError: expected 2 to be 5 // Object.is equality | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-private-static-shadow-exec.test.js:18:25 | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-to-native-fields-half-constructed-static-exec.test.js | ||
Private field '#w' must be declared in an enclosing class | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-to-native-fields-rhs-not-object-exec.test.js | ||
Private field '#p' must be declared in an enclosing class | ||
AssertionError: expected true to be false // Object.is equality | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-to-native-fields-half-constructed-static-exec.test.js:29:15 | ||
|
||
./fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-to-native-fields-static-shadow-exec.test.js | ||
Private field '#x' must be declared in an enclosing class | ||
AssertionError: expected 2 to be 5 // Object.is equality | ||
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-property-in-object-test-fixtures-to-native-fields-static-shadow-exec.test.js:18:25 | ||
|
||
./fixtures/babel/babel-preset-env-test-fixtures-plugins-integration-issue-15170-exec.test.js | ||
AssertionError: expected [Function] to not throw an error but 'ReferenceError: x is not defined' was thrown | ||
|