Avoid naming your types after TypeScript/JavaScript built-ins like Event, Response, Request, or Error. These names compile fine, but cause silent failures during runtime validation.
β οΈ Why This Matters β
When KosmoJS flattens types for schema generation, built-in names are referenced as-is rather than resolved to your custom definition. The validator sees the built-in, not your type, and validation fails at runtime without a compile-time warning.
// β Compiles fine, breaks at runtime
type Event = { id: number; name: string; timestamp: string };
// β
Works correctly
type EventT = { id: number; name: string; timestamp: string };
type TEvent = { id: number; name: string; timestamp: string }; // also fineUse a consistent T suffix (EventT, ResponseT) or prefix (TEvent, TResponse) throughout your project. If validation fails unexpectedly despite correct type definitions, a naming conflict is the first thing to check.
π Common Built-ins to Avoid β
DOM: Event, Element, Document, Window, Node, HTMLElement, EventTarget, CustomEvent
Web APIs: Response, Request, Headers, Body, Blob, File, FormData, URLSearchParams, WebSocket
JavaScript: Error, Date, RegExp, Promise, Symbol, Map, Set, Array, Object, String, Number
TypeScript utilities: Partial, Required, Readonly, Pick, Omit, Record, Exclude, Extract, NonNullable
Node.js: Buffer, Stream, EventEmitter, Timeout
For the full list, see the TFusion builtins reference.