unknown-event
A listener for an event its platform object never dispatches, and nothing in the program does: el.addEventListener("clik", ...) on an HTMLElement, server.on("lisening", ...) on a Node server. On by default, as an error. Reported by safe-ts check only: whether the program dispatches the name somewhere is a question about every file.
Why: addEventListener takes any string. TypeScript checks the name only through the type of the event a listener declares ((e: MouseEvent) => ... on "clik" doesn't compile, because no overload but the one taking any string is left, and it passes an Event); a listener that declares nothing, or Event, compiles with any name, and never runs. Nothing fails: the button simply does nothing.
✅ Accepted: the event's type is declared, so TypeScript checks the name
ts
export function wire(button: HTMLButtonElement, signal: AbortSignal): void {
button.addEventListener("click", (event: MouseEvent) => console.log(event.clientX), { signal });
}❌ Rejected: a name HTMLElement doesn't dispatch, and nothing in the program does
ts
export function wire(el: HTMLElement, signal: AbortSignal): void {
el.addEventListener("clik", () => console.log("clicked"), { signal });
}text
`clik` is not an event of `HTMLElement`, and nothing in the program dispatches it: this listener
never runs
= help: Did you mean `click`? Listen for an event `HTMLElement` dispatchesWhat it knows
The events of each platform class are the browser pack's data (libraries): lib.dom.d.ts's event maps, which TypeScript generates from the specifications. A class's events are its map and the maps that map extends; a value declared with a supertype may be any subtype (HTMLElement: any HTML element, so play is fine; Element and Node: any element; Document: also what bubbles up to window). Needs @evobug_com/safe-ts-feature-browser in "features"; a pack installed before it carried events is read with the checker's own copy.
The receiver's class is what the source writes down: window, document, document.body, a parameter, local or field declared with the class (el: HTMLElement, private readonly canvas: HTMLCanvasElement), new WebSocket(...); and every other written form of its type that calls are resolved through: a loop variable (for (const el of buttons)), an element (items[0], byId.get(id)?.on(...)), a destructured parameter, a member (options.socket), a # field, a parameter property, a forEach callback's parameter, an entry of a Map in for...of. A member of a platform object is the class the packs' creates give it (controller.signal of an AbortController). A name some code of the program dispatches (el.dispatchEvent(new CustomEvent("app:ready")), anywhere: DOM events bubble) is a custom event, and fine. A name that isn't a lowercase word (htmx:load, shown.bs.modal) is taken for a library's custom event and reported only when it is one typo from a known name. On a receiver nothing writes down (el from a helper, document.querySelector(...)), only a name no platform class dispatches that is one typo from one that does (mousedonw).
Node's emitters
The Node pack's events are @types/node's event maps (written from Node's documentation): each class's map (node:http Server: ServerEventMap, extending node:net's), and what a function makes (http.createServer() a Server, spawn() a ChildProcess, the global process a Process). The receiver is a Node object when the source says so: process, new net.Socket(), a const holding what http.createServer(...) or createReadStream(...) returns, a value declared IncomingMessage imported from node:http (or http.IncomingMessage with http a namespace), through the written forms above. A name that isn't a word (custom:thing) is taken for the program's own unless it is a typo of a known one. A plain EventEmitter is the program's, and unmatched-event's.
text
`lisening` is not an event of `Server` (node:http), and nothing in the program emits it: this
listener never runs
= help: Did you mean `listening`? Listen for an event `Server` (node:http) emitsOn an adopter: 65 listeners on Node objects identified (sockets, requests, workers, child processes, process, servers, readline), every name right; 103 of its 254 listeners have a platform class, 82 before the written forms were followed.
What it can't see
- A receiver whose class isn't written down and a name that is a real event of another class (
"message"on an element made by a helper). - Node objects the source doesn't name: one a library returns, a parameter declared with an interface of its own, a socket handed to a callback without a declared type (
server.on("connection", (socket) => socket.on(...))). - Other libraries' emitters (
ws, a database driver): no event list. - A custom event a library dispatches under a plain lowercase name: reported, since nothing in the program dispatches it. Dispatch-side code in
node_modulesisn't read.