From 21beebffb51374b7fe20323e4fcf1ea8349d8e1f Mon Sep 17 00:00:00 2001 From: Dunqing Date: Tue, 24 Dec 2024 15:59:21 +0800 Subject: [PATCH] chore(transformer): enable Babel's private-methods plugin tests --- .../snapshots/babel.snap.md | 496 +++++++++++++++++- .../snapshots/babel_exec.snap.md | 53 +- tasks/transform_conformance/src/constants.rs | 3 +- .../transform_conformance/update_fixtures.mjs | 1 + 4 files changed, 545 insertions(+), 8 deletions(-) diff --git a/tasks/transform_conformance/snapshots/babel.snap.md b/tasks/transform_conformance/snapshots/babel.snap.md index 35e84c82d74b6..be050ea09fa6f 100644 --- a/tasks/transform_conformance/snapshots/babel.snap.md +++ b/tasks/transform_conformance/snapshots/babel.snap.md @@ -1,12 +1,10 @@ commit: 54a8389f -Passed: 604/927 +Passed: 622/1095 # All Passed: -* babel-plugin-transform-class-static-block * babel-plugin-transform-logical-assignment-operators * babel-plugin-transform-optional-catch-binding -* babel-plugin-transform-async-generator-functions * babel-preset-react * babel-plugin-transform-react-display-name * babel-plugin-transform-react-jsx-self @@ -276,7 +274,7 @@ x Output mismatch x Output mismatch -# babel-plugin-transform-class-properties (211/264) +# babel-plugin-transform-class-properties (212/268) * assumption-constantSuper/complex-super-class/input.js x Output mismatch @@ -359,6 +357,9 @@ x Output mismatch * private/static-infer-name/input.js x Output mismatch +* private/static-self-method/input.js +x Output mismatch + * private/static-shadow/input.js x Output mismatch @@ -440,6 +441,483 @@ x Output mismatch * regression/6153/input.js x Output mismatch +* source-maps/private-get/input.js +x Output mismatch + +* source-maps/private-set/input.js +x Output mismatch + + +# babel-plugin-transform-class-static-block (17/21) +* integration/in-class-heritage/input.js +x Output mismatch + +* integration/new-target/input.js +x Output mismatch + +* integration-loose/in-class-heritage/input.js +x Output mismatch + +* integration-loose/super-static-block/input.js +x Output mismatch + + +# babel-plugin-transform-private-methods (7/148) +* accessors/arguments/input.js +x Output mismatch + +* accessors/basic/input.js +x Output mismatch + +* accessors/class-binding/input.js +x Output mismatch + +* accessors/destructuring/input.js +x Output mismatch + +* accessors/get-only-setter/input.js +x Output mismatch + +* accessors/preserve-comments/input.js +x Output mismatch + +* accessors/reassignment/input.js +x Output mismatch + +* accessors/set-only-getter/input.js +x Output mismatch + +* accessors/tagged-template/input.js +x Output mismatch + +* accessors/updates/input.js +x Output mismatch + +* accessors/updates-bigint/input.js +x Output mismatch + +* accessors-loose/basic/input.js +x Output mismatch + +* accessors-loose/class-binding/input.js +x Output mismatch + +* accessors-loose/get-only-setter/input.js +x Output mismatch + +* accessors-loose/preserve-comments/input.js +x Output mismatch + +* accessors-loose/reassignment/input.js +x Output mismatch + +* accessors-loose/set-only-getter/input.js +x Output mismatch + +* accessors-loose/updates/input.js +x Output mismatch + +* accessors-privateFieldsAsProperties/basic/input.js +x Output mismatch + +* accessors-privateFieldsAsProperties/class-binding/input.js +x Output mismatch + +* accessors-privateFieldsAsProperties/get-only-setter/input.js +x Output mismatch + +* accessors-privateFieldsAsProperties/preserve-comments/input.js +x Output mismatch + +* accessors-privateFieldsAsProperties/set-only-getter/input.js +x Output mismatch + +* accessors-privateFieldsAsProperties/updates/input.js +x Output mismatch + +* accessors-privateFieldsAsSymbols/basic/input.js +x Output mismatch + +* accessors-privateFieldsAsSymbols/class-binding/input.js +x Output mismatch + +* accessors-privateFieldsAsSymbols/get-only-setter/input.js +x Output mismatch + +* accessors-privateFieldsAsSymbols/preserve-comments/input.js +x Output mismatch + +* accessors-privateFieldsAsSymbols/set-only-getter/input.js +x Output mismatch + +* accessors-privateFieldsAsSymbols/updates/input.js +x Output mismatch + +* assumption-constantSuper/private-method-super/input.js +x Output mismatch + +* duplicated-names/get-set/input.js +x Output mismatch + +* duplicated-names/set-get/input.js +x Output mismatch + +* misc/multiple/input.js +x Output mismatch + +* private-method/assignment/input.js +x Output mismatch + +* private-method/async/input.js +x Output mismatch + +* private-method/before-fields/input.js +x Output mismatch + +* private-method/class-binding/input.js +x Output mismatch + +* private-method/class-expression/input.js +x Output mismatch + +* private-method/context/input.js +x Output mismatch + +* private-method/destructuring/input.js +x Output mismatch + +* private-method/exfiltrated/input.js +x Output mismatch + +* private-method/generator/input.js +x Output mismatch + +* private-method/preserve-comments/input.js +x Output mismatch + +* private-method/read-only/input.js +x Output mismatch + +* private-method/reassignment/input.js +x Output mismatch + +* private-method/super/input.js +x Output mismatch + +* private-method/tagged-template/input.js +x Output mismatch + +* private-method-loose/assignment/input.js +x Output mismatch + +* private-method-loose/async/input.js +x Output mismatch + +* private-method-loose/before-fields/input.js +x Output mismatch + +* private-method-loose/class-binding/input.js +x Output mismatch + +* private-method-loose/class-expression/input.js +x Output mismatch + +* private-method-loose/context/input.js +x Output mismatch + +* private-method-loose/exfiltrated/input.js +x Output mismatch + +* private-method-loose/generator/input.js +x Output mismatch + +* private-method-loose/preserve-comments/input.js +x Output mismatch + +* private-method-loose/reassignment/input.js +x Output mismatch + +* private-method-loose/super/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/assignment/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/async/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/before-fields/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/class-binding/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/class-expression/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/context/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/exfiltrated/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/generator/input.js +x Output mismatch + +* private-method-privateFieldsAsProperties/super/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/assignment/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/async/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/before-fields/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/class-binding/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/class-expression/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/context/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/exfiltrated/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/generator/input.js +x Output mismatch + +* private-method-privateFieldsAsSymbols/super/input.js +x Output mismatch + +* private-static-method/async/input.js + + x TS(1108): A 'return' statement can only be used within a function body. + ,-[tasks/coverage/babel/packages/babel-plugin-transform-private-methods/test/fixtures/private-static-method/async/input.js:11:1] + 10 | + 11 | return new Cl().test().then(val => { + : ^^^^^^ + 12 | expect(val).toBe(2); + `---- + + +* private-static-method/basic/input.js +x Output mismatch + +* private-static-method/class-check/input.js +x Output mismatch + +* private-static-method/class-expression/input.js +x Output mismatch + +* private-static-method/exfiltrated/input.js +x Output mismatch + +* private-static-method/generator/input.js +x Output mismatch + +* private-static-method/preserve-comments/input.js +x Output mismatch + +* private-static-method/read-only/input.js +x Output mismatch + +* private-static-method/super/input.js +x Output mismatch + +* private-static-method/tagged-template/input.js +x Output mismatch + +* private-static-method/this/input.js +x Output mismatch + +* private-static-method-loose/async/input.js + + x TS(1108): A 'return' statement can only be used within a function body. + ,-[tasks/coverage/babel/packages/babel-plugin-transform-private-methods/test/fixtures/private-static-method-loose/async/input.js:11:1] + 10 | + 11 | return new Cl().test().then(val => { + : ^^^^^^ + 12 | expect(val).toBe(2); + `---- + + +* private-static-method-loose/basic/input.js +x Output mismatch + +* private-static-method-loose/class-check/input.js +x Output mismatch + +* private-static-method-loose/class-expression/input.js +x Output mismatch + +* private-static-method-loose/exfiltrated/input.js +x Output mismatch + +* private-static-method-loose/generator/input.js +x Output mismatch + +* private-static-method-loose/preserve-comments/input.js +x Output mismatch + +* private-static-method-loose/reassignment/input.js +x Output mismatch + +* private-static-method-loose/super/input.js +x Output mismatch + +* private-static-method-loose/this/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/async/input.js + + x TS(1108): A 'return' statement can only be used within a function body. + ,-[tasks/coverage/babel/packages/babel-plugin-transform-private-methods/test/fixtures/private-static-method-privateFieldsAsProperties/async/input.js:11:1] + 10 | + 11 | return new Cl().test().then(val => { + : ^^^^^^ + 12 | expect(val).toBe(2); + `---- + + +* private-static-method-privateFieldsAsProperties/basic/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/class-check/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/class-expression/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/exfiltrated/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/generator/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/reassignment/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/super/input.js +x Output mismatch + +* private-static-method-privateFieldsAsProperties/this/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/async/input.js + + x TS(1108): A 'return' statement can only be used within a function body. + ,-[tasks/coverage/babel/packages/babel-plugin-transform-private-methods/test/fixtures/private-static-method-privateFieldsAsSymbols/async/input.js:11:1] + 10 | + 11 | return new Cl().test().then(val => { + : ^^^^^^ + 12 | expect(val).toBe(2); + `---- + + +* private-static-method-privateFieldsAsSymbols/basic/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/class-check/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/class-expression/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/exfiltrated/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/generator/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/reassignment/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/super/input.js +x Output mismatch + +* private-static-method-privateFieldsAsSymbols/this/input.js +x Output mismatch + +* static-accessors/basic/input.js +x Output mismatch + +* static-accessors/destructure-set/input.js +x Output mismatch + +* static-accessors/get-only-setter/input.js +x Output mismatch + +* static-accessors/preserve-comments/input.js +x Output mismatch + +* static-accessors/set-only-getter/input.js +x Output mismatch + +* static-accessors/tagged-template/input.js +x Output mismatch + +* static-accessors/updates/input.js +x Output mismatch + +* static-accessors-loose/basic/input.js +x Output mismatch + +* static-accessors-loose/destructure-set/input.js +x Output mismatch + +* static-accessors-loose/get-only-setter/input.js +x Output mismatch + +* static-accessors-loose/preserve-comments/input.js +x Output mismatch + +* static-accessors-loose/set-only-getter/input.js +x Output mismatch + +* static-accessors-loose/updates/input.js +x Output mismatch + +* static-accessors-privateFieldsAsProperties/basic/input.js +x Output mismatch + +* static-accessors-privateFieldsAsProperties/destructure-set/input.js +x Output mismatch + +* static-accessors-privateFieldsAsProperties/get-only-setter/input.js +x Output mismatch + +* static-accessors-privateFieldsAsProperties/preserve-comments/input.js +x Output mismatch + +* static-accessors-privateFieldsAsProperties/set-only-getter/input.js +x Output mismatch + +* static-accessors-privateFieldsAsProperties/updates/input.js +x Output mismatch + +* static-accessors-privateFieldsAsSymbols/basic/input.js +x Output mismatch + +* static-accessors-privateFieldsAsSymbols/destructure-set/input.js +x Output mismatch + +* static-accessors-privateFieldsAsSymbols/get-only-setter/input.js +x Output mismatch + +* static-accessors-privateFieldsAsSymbols/preserve-comments/input.js +x Output mismatch + +* static-accessors-privateFieldsAsSymbols/set-only-getter/input.js +x Output mismatch + +* static-accessors-privateFieldsAsSymbols/updates/input.js +x Output mismatch + # babel-plugin-transform-nullish-coalescing-operator (5/12) * assumption-noDocumentAll/transform/input.js @@ -769,6 +1247,11 @@ after transform: ["ExampleType", "o"] rebuilt : ["o"] +# babel-plugin-transform-async-generator-functions (19/20) +* async-generators/class-private-method/input.js +x Output mismatch + + # babel-plugin-transform-object-rest-spread (28/36) * object-rest/for-x/input.js Bindings mismatch: @@ -1140,7 +1623,7 @@ x Output mismatch x Output mismatch -# babel-plugin-transform-typescript (47/156) +# babel-plugin-transform-typescript (47/157) * cast/as-expression/input.ts Unresolved references mismatch: after transform: ["T", "x"] @@ -1190,6 +1673,9 @@ Scope children mismatch: after transform: ScopeId(1): [ScopeId(2), ScopeId(3), ScopeId(4)] rebuilt : ScopeId(1): [ScopeId(2)] +* class/private-method-override-transform-private/input.ts +x Output mismatch + * declarations/const-enum/input.ts Bindings mismatch: after transform: ScopeId(0): ["E"] diff --git a/tasks/transform_conformance/snapshots/babel_exec.snap.md b/tasks/transform_conformance/snapshots/babel_exec.snap.md index aaceafc4927f3..942123f65080e 100644 --- a/tasks/transform_conformance/snapshots/babel_exec.snap.md +++ b/tasks/transform_conformance/snapshots/babel_exec.snap.md @@ -2,7 +2,7 @@ commit: 54a8389f node: v22.12.0 -Passed: 195 of 215 (90.70%) +Passed: 330 of 362 (91.16%) Failures: @@ -78,6 +78,22 @@ 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 +Private field '#foo' must be declared in an enclosing class + +./fixtures/babel/babel-plugin-transform-class-static-block-test-fixtures-integration-new-target-exec.test.js +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-class-static-block-test-fixtures-integration-private-methods-access-exec.test.js +Private field '#foo' 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) @@ -96,6 +112,41 @@ TypeError: Cannot read properties of undefined (reading 'x') at Foo.test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-loose-exec.test.js:25:63) at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-optional-chaining-test-fixtures-general-parenthesized-expression-member-call-loose-exec.test.js:68:12 +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-loose-get-only-setter-exec.test.js +TypeError: '#privateFieldValue' was defined without a getter + at new Cl (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-loose-get-only-setter-exec.test.js:16:16) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-loose-get-only-setter-exec.test.js:19:13 + +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-privateFieldsAsProperties-get-only-setter-exec.test.js +TypeError: '#privateFieldValue' was defined without a getter + at new Cl (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-privateFieldsAsProperties-get-only-setter-exec.test.js:16:16) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-privateFieldsAsProperties-get-only-setter-exec.test.js:19:13 + +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js +TypeError: '#privateFieldValue' was defined without a getter + at new Cl (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js:13:16) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js:16:13 + +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-get-only-setter-exec.test.js +TypeError: '#privateStaticFieldValue' was defined without a getter + at Function.getPrivateStaticFieldValue (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-get-only-setter-exec.test.js:9:14) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-get-only-setter-exec.test.js:13:12 + +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-loose-get-only-setter-exec.test.js +TypeError: '#privateStaticFieldValue' was defined without a getter + at Function.getPrivateStaticFieldValue (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-loose-get-only-setter-exec.test.js:12:14) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-loose-get-only-setter-exec.test.js:19:12 + +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsProperties-get-only-setter-exec.test.js +TypeError: '#privateStaticFieldValue' was defined without a getter + at Function.getPrivateStaticFieldValue (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsProperties-get-only-setter-exec.test.js:12:14) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsProperties-get-only-setter-exec.test.js:19:12 + +./fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js +TypeError: '#privateStaticFieldValue' was defined without a getter + at Function.getPrivateStaticFieldValue (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js:9:14) + at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-private-methods-test-fixtures-static-accessors-privateFieldsAsSymbols-get-only-setter-exec.test.js:13:12 + ./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 at Proxy. (./node_modules/.pnpm/@vitest+expect@2.1.2/node_modules/@vitest/expect/dist/index.js:1438:21) diff --git a/tasks/transform_conformance/src/constants.rs b/tasks/transform_conformance/src/constants.rs index 94770bb4c1aac..0e847e2e09fc3 100644 --- a/tasks/transform_conformance/src/constants.rs +++ b/tasks/transform_conformance/src/constants.rs @@ -5,7 +5,7 @@ pub const PLUGINS: &[&str] = &[ // // ES2022 "babel-plugin-transform-class-properties", "babel-plugin-transform-class-static-block", - // "babel-plugin-transform-private-methods", + "babel-plugin-transform-private-methods", // "babel-plugin-transform-private-property-in-object", // // [Syntax] "babel-plugin-transform-syntax-top-level-await", // ES2021 @@ -67,7 +67,6 @@ pub const PLUGINS_NOT_SUPPORTED_YET: &[&str] = &[ "transform-destructuring", "transform-modules-commonjs", "transform-parameters", - "transform-private-methods", "transform-property-literals", "transform-react-constant-elements", ]; diff --git a/tasks/transform_conformance/update_fixtures.mjs b/tasks/transform_conformance/update_fixtures.mjs index 1115ecf56343d..fc45968ff241c 100644 --- a/tasks/transform_conformance/update_fixtures.mjs +++ b/tasks/transform_conformance/update_fixtures.mjs @@ -18,6 +18,7 @@ import { extname, join as pathJoin } from 'path'; const PACKAGES = [ 'babel-plugin-transform-class-properties', + 'babel-plugin-transform-private-methods', 'babel-plugin-transform-logical-assignment-operators', ]; const FILTER_OUT_PRESETS = ['env'];