Skip to content

Commit

Permalink
remove
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Mar 2, 2025
1 parent 49a160e commit 8285bca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
8 changes: 6 additions & 2 deletions packages/babel-traverse/src/path/evaluation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ function _evaluate(path: NodePath, state: State): any {
}
}
}
if (binding.hasValue) {
return binding.value;
if (!process.env.BABEL_8_BREAKING) {
// @ts-expect-error Removed in Babel 8
if (binding.hasValue) {
// @ts-expect-error Removed in Babel 8
return binding.value;
}
}
}

Expand Down
54 changes: 32 additions & 22 deletions packages/babel-traverse/src/scope/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export default class Binding {
this.reassign(path);
}

this.clearValue();
if (!process.env.BABEL_8_BREAKING) {
// @ts-expect-error Removed in Babel 8
this.clearValue();
}
}

constantViolations: Array<NodePath> = [];
Expand All @@ -58,27 +61,6 @@ export default class Binding {
referenced: boolean = false;
references: number = 0;

declare hasDeoptedValue: boolean;
declare hasValue: boolean;
declare value: any;

deoptValue() {
this.clearValue();
this.hasDeoptedValue = true;
}

setValue(value: any) {
if (this.hasDeoptedValue) return;
this.hasValue = true;
this.value = value;
}

clearValue() {
this.hasDeoptedValue = false;
this.hasValue = false;
this.value = null;
}

/**
* Register a constant violation with the provided `path`.
*/
Expand Down Expand Up @@ -114,6 +96,34 @@ export default class Binding {
}
}

if (!process.env.BABEL_8_BREAKING) {
// @ts-expect-error Removed in Babel 8
Binding.prototype.deoptValue = function () {
// @ts-expect-error Removed in Babel 8
this.clearValue();
// @ts-expect-error Removed in Babel 8
this.hasDeoptedValue = true;
};
// @ts-expect-error Removed in Babel 8
Binding.prototype.setValue = function (value) {
// @ts-expect-error Removed in Babel 8
if (this.hasDeoptedValue) return;
// @ts-expect-error Removed in Babel 8
this.hasValue = true;
// @ts-expect-error Removed in Babel 8
this.value = value;
};
// @ts-expect-error Removed in Babel 8
Binding.prototype.clearValue = function () {
// @ts-expect-error Removed in Babel 8
this.hasDeoptedValue = false;
// @ts-expect-error Removed in Babel 8
this.hasValue = false;
// @ts-expect-error Removed in Babel 8
this.value = null;
};
}

function isDeclaredInLoop(path: NodePath) {
for (
let { parentPath, key } = path;
Expand Down

0 comments on commit 8285bca

Please sign in to comment.