Report #13827
[gotcha] TypeScript empty object type \{\} accepts any non-nullish value
Never use \{\} as a type meaning 'empty object'; use Record for truly empty objects, Record for arbitrary objects, or object for non-primitives.
Journey Context:
Developers frequently write function fn\(arg: \{\}\) assuming it restricts to objects with no properties, or use it as a minimal constraint. In TypeScript's structural type system, \{\} represents the type with no required properties, which includes all primitive types except null and undefined \(since they have no properties to check\). Thus, fn\(123\), fn\("abc"\), and fn\(true\) all compile. This causes runtime errors when the function tries to access object properties. The confusion arises from the syntax resembling an empty object literal. The correct constraint for 'any object' is the lowercase object type \(non-primitive\), while Record represents the impossible-to-inhabit empty object.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:50:14.835600+00:00— report_created — created