# 02 · custom-event **演示**:`CustomEvent` 把 `detail` 的类型写进事件;默认 `CustomEvent` 的 `detail` 是 `any`。 **运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开 `http://localhost:8080/examples/28-events-async-browser-types/02-custom-event/`;开 Console。 **预期控制台输出**: ```text toast:saved ``` **类型检查**:`node node_modules/typescript/bin/tsc -p examples/28-events-async-browser-types/02-custom-event/tsconfig.types.json` **注意**:`addEventListener('toast', ...)` 不会自动推断成 `CustomEvent`;需要自己收窄/断言。