Repository navigation
Open
Description
🔎 Search Terms
commonjs emit parenthesized call this, (0, a_1.f), indirect call wrapped callee, satisfies call this
🕗 Version & Regression Information
Not a regression.
- Fails: 5.9.3, 6.0.3, 7.0.2, 7.1.0-dev.20261106.1, 7.1.0-dev.20261109.1
⏯ Playground Link
(Playground v2, 6.0.3, module: commonjs; press Run.)
💻 Code
// a.ts
export function f(this: unknown) { return this; }
// index.ts
import { f } from "./a";
type F = () => unknown;
console.log(f() === undefined); // true emit: (0, a_1.f)()
console.log((f)() === undefined); // false emit: (a_1.f)()
console.log((f as F)() === undefined); // false emit: a_1.f()
console.log((f!)() === undefined); // false emit: (a_1.f)()
console.log((f satisfies F)() === undefined); // false emit: a_1.f()
console.log((f)`x` === undefined); // false emit: (a_1.f) `x`🙁 Actual behavior
Only the bare call f() is emitted as (0, a_1.f)(). When the callee is parenthesized or wrapped in as, <F>, ! or satisfies, the emit calls a_1.f as a method, so this is the exports object instead of undefined.
🙂 Expected behavior
All six calls print true, as in ESM output: the wrapped forms should also be emitted as (0, a_1.f)(...).
This was found with an AI-assisted differential testing tool; the repros and outputs above were re-run on the listed versions.
Metadata
Metadata
Assignees
Labels
No labels
Activity