Skip to content

Commit

Permalink
Merge pull request #1 from cokyman/class-private-fields-avoid-descrip…
Browse files Browse the repository at this point in the history
…tors

Class private fields avoid descriptors
  • Loading branch information
cokyman authored Oct 12, 2024
2 parents b2bbffb + deedbe6 commit 23ab5c2
Show file tree
Hide file tree
Showing 511 changed files with 3,316 additions and 3,527 deletions.
5 changes: 5 additions & 0 deletions .github/CHANGELOG-v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ This file contains the changelog starting from v8.0.0-alpha.0.

<!-- DO NOT CHANGE THESE COMMENTS -->
<!-- insert-new-changelog-here -->
## v8.0.0-alpha.6 (2024-01-26)

#### :nail_care: Polish
* `babel-register`
* [#16005](https://github.com/babel/babel/pull/16005) Use `@cspotcode/source-map-support` in `@babel/register` ([@liuxingbaoyu](https://github.com/liuxingbaoyu))
## v8.0.0-alpha.5 (2023-12-11)

#### :boom: Breaking Change
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ jobs:
token: ${{ secrets.BOT_TOKEN }}
repository: babel/website
branch: update-types-docs
base: main
title: Update Babel types docs
description: Updated `@babel/types` docs for [Babel ${{ needs.github-release.outputs.version }}](https://github.com/babel/babel/releases/tag/${{ needs.github-release.outputs.version }}).
labels: |
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,42 @@ This file contains the changelog starting from v7.15.0.

<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
<!-- insert-new-changelog-here -->
## v7.23.10 (2024-01-31)

#### :bug: Bug Fix
* Other
* [#16240](https://github.com/babel/babel/pull/16240) [eslint] Include field decorators in scope analysis ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`
* [#16235](https://github.com/babel/babel/pull/16235) Fix `protoInit` call injection timing ([@JLHwung](https://github.com/JLHwung))
## v7.23.9 (2024-01-25)

#### :bug: Bug Fix
* `babel-helper-transform-fixture-test-runner`, `babel-plugin-transform-function-name`, `babel-plugin-transform-modules-systemjs`, `babel-preset-env`
* [#16225](https://github.com/babel/babel/pull/16225) fix: `systemjs` re-traverses helpers ([@liuxingbaoyu](https://github.com/liuxingbaoyu))
* `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`
* [#16226](https://github.com/babel/babel/pull/16226) Improve decorated private method check ([@JLHwung](https://github.com/JLHwung))
* `babel-plugin-proposal-decorators`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-runtime`, `babel-preset-env`
* [#16224](https://github.com/babel/babel/pull/16224) Properly sort `core-js@3` imports ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-traverse`
* [#15383](https://github.com/babel/babel/pull/15383) fix: Don't throw in `getTypeAnnotation` when using TS+inference ([@liuxingbaoyu](https://github.com/liuxingbaoyu))
* Other
* [#16210](https://github.com/babel/babel/pull/16210) [eslint] Fix `no-use-before-define` for class ref in fields ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))

#### :house: Internal
* `babel-core`, `babel-parser`, `babel-template`
* [#16222](https://github.com/babel/babel/pull/16222) Migrate `eslint-parser` to cts ([@liuxingbaoyu](https://github.com/liuxingbaoyu))
* `babel-types`
* [#16213](https://github.com/babel/babel/pull/16213) Remove `@babel/types` props that are not produced by the parser ([@liuxingbaoyu](https://github.com/liuxingbaoyu))

#### :running_woman: Performance
* `babel-parser`
* [#16072](https://github.com/babel/babel/pull/16072) perf: Improve parser performance for typescript ([@liuxingbaoyu](https://github.com/liuxingbaoyu))

#### :microscope: Output optimization
* `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-decorators`, `babel-plugin-proposal-destructuring-private`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-class-properties`, `babel-plugin-transform-class-static-block`, `babel-plugin-transform-new-target`, `babel-plugin-transform-parameters`, `babel-plugin-transform-private-methods`, `babel-preset-env`
* [#16218](https://github.com/babel/babel/pull/16218) Improve temporary variables for decorators ([@liuxingbaoyu](https://github.com/liuxingbaoyu))
* `babel-helpers`, `babel-plugin-proposal-explicit-resource-management`, `babel-runtime-corejs2`, `babel-runtime-corejs3`, `babel-runtime`
* [#15959](https://github.com/babel/babel/pull/15959) Improve output of `using` ([@liuxingbaoyu](https://github.com/liuxingbaoyu))
## v7.23.8 (2024-01-08)

#### :bug: Bug Fix
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FLOW_COMMIT = 105ad30f566f401db9cafcb49cd2831fb29e87c5
TEST262_COMMIT = 17ba9aea47e496f5b2bc6ce7405b3f32e3cfbf7a
TEST262_COMMIT = 584048ed081d85f5eed6e884a7b40b6f4bcd67d7
TYPESCRIPT_COMMIT = d87d0adcd30ac285393bf3bfbbb4d94d50c4f3c9

SOURCES = packages codemods eslint
Expand Down
4 changes: 2 additions & 2 deletions Makefile.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions Makefile.source.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,24 @@ target["bootstrap-flow"] = function () {

target["new-version-checklist"] = function () {
// eslint-disable-next-line no-constant-condition
if (1) {
if (0) {
console.log(
`
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!! !!!!!!
!!!!!! Write any important message here, and change the !!!!!!
!!!!!! if (0) above to if (1) !!!!!!
!!!!!! !!!!!!
!!!!!! - Update usingCtx helper version !!!!!!
- Update the version:
- classCheckPrivateStaticAccess
- assertClassBrand
- classPrivateFieldGet2
- classPrivateFieldSet2
- classPrivateGetter
- classPrivateSetter
- toSetter
!!!!!! !!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
19 changes: 14 additions & 5 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports = function (api) {
"packages/babel-runtime/regenerator"
);
targets = { ie: 7 };
needsPolyfillsForOldNode = true;
break;
case "rollup":
convertESM = false;
Expand Down Expand Up @@ -183,10 +184,6 @@ module.exports = function (api) {
["@babel/transform-object-rest-spread", { useBuiltIns: true }],

convertESM ? "@babel/transform-export-namespace-from" : null,

pluginPackageJsonMacro,

needsPolyfillsForOldNode && pluginPolyfillsOldNode,
].filter(Boolean),
overrides: [
{
Expand Down Expand Up @@ -250,6 +247,10 @@ module.exports = function (api) {
},
"flag-BABEL_8_BREAKING",
],

pluginPackageJsonMacro,

needsPolyfillsForOldNode && pluginPolyfillsOldNode,
].filter(Boolean),
},
convertESM && {
Expand Down Expand Up @@ -391,7 +392,6 @@ function bool(value) {
// copy and paste it.
// `((v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1]))`;

// TODO(Babel 8) This polyfills are only needed for Node.js 6 and 8
/** @param {import("@babel/core")} api */
function pluginPolyfillsOldNode({ template, types: t }) {
const polyfills = [
Expand Down Expand Up @@ -468,6 +468,15 @@ function pluginPolyfillsOldNode({ template, types: t }) {
process.allowedNodeEnvironmentFlags || require("node-environment-flags")
`,
},
{
name: "Object.hasOwn",
necessary: () => true,
supported: path =>
path.parentPath.isCallExpression({ callee: path.node }),
// Object.hasOwn has been introduced in Node.js 16.9.0
// https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V16.md#v8-93
replacement: template`hasOwnProperty.call`,
},
];

return {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"@babel/types": "workspace:^",
"benchmark": "^2.1.4"
},
"version": "7.23.4"
"version": "7.23.9"
}
2 changes: 1 addition & 1 deletion eslint/babel-eslint-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@babel/eslint-parser",
"version": "7.23.3",
"version": "7.23.10",
"description": "ESLint parser that allows for linting of experimental syntax transformed by Babel",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion eslint/babel-eslint-parser/src/analyze-scope.cts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ class Referencer extends OriginalReferencer {
}

_visitClassProperty(node: any) {
const { computed, key, typeAnnotation, value } = node;
const { computed, key, typeAnnotation, decorators, value } = node;

this._visitArray(decorators);
if (computed) this.visit(key);
this._visitTypeAnnotation(typeAnnotation);

Expand Down
31 changes: 31 additions & 0 deletions eslint/babel-eslint-tests/test/integration/eslint/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,37 @@ describe("verify", () => {
});
});

describe("decorators #16239", () => {
it("field decorators count as usage for no-unused-vars", () => {
verifyAndAssertMessages(
`
import { tracked } from '@glimmer/tracking';
class State {
@tracked depth = 0;
}
new State();
`,
{ "no-unused-vars": 1 },
);
});
it("method decorators count as usage for no-unused-vars", () => {
verifyAndAssertMessages(
`
import { tracked } from '@glimmer/tracking';
class State {
@tracked depth() { return 0; }
}
new State();
`,
{ "no-unused-vars": 1 },
);
});
});

it("detects minimal no-unused-vars case #120", () => {
verifyAndAssertMessages("var unused;", { "no-unused-vars": 1 }, [
"1:5 'unused' is defined but never used. no-unused-vars",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "babel",
"version": "7.23.8",
"version_babel8": "8.0.0-alpha.5",
"version": "7.23.10",
"version_babel8": "8.0.0-alpha.6",
"private": true,
"type": "commonjs",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.23.4",
"version": "7.23.9",
"description": "Babel command line.",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-cli",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.23.7",
"version": "7.23.9",
"description": "Babel compiler core.",
"main": "./lib/index.js",
"author": "The Babel Team (https://babel.dev/team)",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/src/config/config-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {

// "sourceMap" is just aliased to sourceMap, so copy it over as
// we merge the options together.
if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) {
if (Object.hasOwn(options, "sourceMap")) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export function assertTargets(

if (key === "esmodules") assertBoolean(subLoc, val);
else if (key === "browsers") assertBrowsersList(subLoc, val);
else if (!Object.hasOwnProperty.call(TargetNames, key)) {
else if (!Object.hasOwn(TargetNames, key)) {
const validTargets = Object.keys(TargetNames).join(", ");
throw new Error(
`${msg(
Expand Down
6 changes: 1 addition & 5 deletions packages/babel-core/src/config/validation/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,8 @@ function throwUnknownError(loc: OptionPath) {
}
}

function has(obj: {}, key: string) {
return Object.prototype.hasOwnProperty.call(obj, key);
}

function assertNoDuplicateSourcemap(opts: {}): void {
if (has(opts, "sourceMap") && has(opts, "sourceMaps")) {
if (Object.hasOwn(opts, "sourceMap") && Object.hasOwn(opts, "sourceMaps")) {
throw new Error(".sourceMap is an alias for .sourceMaps, cannot use both");
}
}
Expand Down
Loading

0 comments on commit 23ab5c2

Please sign in to comment.