Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsTypeScript has no general type that guarantees a value has exactly zero properties. In particular, {} does not mean “empty object”: with strictNullChecks enabled, it accepts any non-nullish value, including primitives. Choose a type for the constraint you actually need, and validate at runtime if the absence of properties matters.
What does {} mean in TypeScript?
With strictNullChecks enabled, {} accepts any value other than null or undefined. That includes strings, numbers, booleans, and objects. It does not require a value to be an object, much less an object with no properties.
const text: {} = "hello";
const value: {} = { extra: true };
The TypeScript project FAQ explains that because TypeScript has no sealed or closed types, there is no type that refers to values with zero properties: TypeScript FAQ: “Primitives are {}, and {} Doesn’t Mean object”. With strictNullChecks disabled, nullability behavior differs, so avoid treating the examples above as configuration-independent. The Handbook recommends enabling strict null checking: TypeScript Handbook: Basic Types.
Which type should you use instead?
Start with the intended constraint. These types are not interchangeable: {} concerns nullish values, object excludes primitives, and unknown is for values not yet inspected.
#1 Best Overall
| Need | Starting type | What it permits or requires |
|---|---|---|
| Any non-nullish value | {} |
Primitives and objects; not null or undefined when strictNullChecks is enabled. It does not mean empty. |
| Any non-primitive value | object |
Objects, arrays, and functions; does not prohibit properties. TypeScript Handbook |
| Arbitrary input that has not been inspected | unknown |
Any value, including nullish values; narrow it before using it as a specific type. TypeScript Handbook |
| A known configuration or data shape | A named object type or interface | Declares the properties the program expects; structural typing does not generally forbid additional properties. TypeScript Handbook: Object Types |
| No own enumerable string-keyed properties at runtime | Runtime validation | Check the actual value and decide whether symbols, non-enumerable properties, or inherited keys count as “empty.” |
How do you type a known object shape?
If the value has a meaningful shape, describe that shape instead of trying to express a universal empty object. Optional properties allow callers to omit a property; they do not create a sealed type that rejects every additional property in every assignment context.
type Options = {
mode?: "fast" | "safe";
};
const options: Options = { mode: "fast" };
TypeScript can report an excess-property error when a fresh object literal includes a property not declared by the target type. This is a useful typo check, not a general exact-object guarantee: other values and assignment routes can still carry additional properties. See the Handbook’s discussion of excess property checks.
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Why not use Record<string, never>?
Record<Keys, Type> is a mapped utility type for giving a selected set of keys a value type; it is useful for dictionary-like types. It is not a general switch for sealed, exact objects. The TypeScript FAQ specifically rejects using this kind of Record as a way to express its non-nullish-value meaning. See TypeScript Handbook: Utility Types and the TypeScript FAQ.
How can you check that a value is empty at runtime?
First define “empty” for your application. The following helper checks that a value is a non-null object and has no own enumerable string-keyed properties:
function hasNoEnumerableStringKeys(value: unknown): boolean {
return typeof value === "object" &&
value !== null &&
Object.keys(value).length === 0;
}
Object.keys does not count symbol keys, non-enumerable properties, or inherited properties. If any of those should make a value non-empty, use a validation rule that checks them too. This is runtime validation of a concrete value, not a compile-time guarantee about every value assignable to a type.
For untrusted input, accepting unknown and then narrowing is safer than claiming it already has a particular object shape:
function inspect(value: unknown) {
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
// The value is object-like; its properties are not yet known.
}
}
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What about unconstrained generic types?
Older TypeScript code may rely on an unconstrained generic parameter behaving as though it had an implicit {} constraint. TypeScript 3.5 changed unconstrained generic parameters to use unknown instead. That change reflects the distinction between an arbitrary value and a value known to satisfy a narrower constraint. See the TypeScript breaking changes for 3.5.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




