@studnicky/v8/with-statement
Disallows with statements. The with statement makes scope resolution dynamic — V8 cannot determine at compile time which binding a variable name refers to, so it cannot generate optimized code for the entire surrounding function.
Fixable: No · Options: No · Suggested severity: error
✗ Incorrect
ts
// @ts-ignore — shown for documentation only; with is not valid in strict mode
with (Math) {
const r = sqrt(pow(x, 2) + pow(y, 2));
}✓ Correct
ts
// Use explicit object access
const r = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));ts
// Or destructure once at the call site
const { sqrt, pow } = Math;
const r = sqrt(pow(x, 2) + pow(y, 2));