Closed
Description
Bug Report
🕗 Version & Regression Information
When did you start seeing this bug occur?
TypeScript 4.4
If possible, please try testing the nightly version of TS to see if it's already been fixed.
Nope. 4.5.0-dev.20210923 emits the same .js as 4.4.3.
- ✔️ This is a crash
- ✔️ This changed between versions 4.3.5 and 4.4.3
This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________I was unable to test this on prior versions because _______
⏯ Playground Link
Playground renders correct javascript.
💻 Code
I've reproduced the issue in this repository: https://github.com/mceachen/ts44-event-typeerror
-
The first commit uses TypeScript 4.3.5, and
tsc --init
with no edits. I also committed the javascript file emitted bytsc
. -
The second commit just upgrades TypeScript to 4.4.3, rebuilds the yarn.lock, and recompiles. The invalid javascript is visible:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var process_1 = require("process");
(0, process_1.addListener)("SIGINT", function (evt) {
console.log("caught SIGINT", evt);
});
console.log("GREAT SUCCESS");
🙁 Actual behavior
With both node 14.17.6 and 16.10.0, the same error emits:
node:events:425
events = target._events;
^
TypeError: Cannot read properties of undefined (reading '_events')
at _addListener (node:events:425:19)
at addListener (node:events:487:10)
at Object.<anonymous> (/home/mrm/src/ts44-event-typeerror/test.js:4:27)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
🙂 Expected behavior
What I saw with TypeScript 4.3, which didn't have the (0,
prefix in front of every method call.