[TypeScript] Treat an empty object as an interface type

Created on November 28, 2026

You can use a type assertion of the form as Type to treat an empty object as a particular interface type. This example assigns {} to d by asserting that it is of type DummyInterface.

interface DummyInterface {
  name: string;
  age: number;
}

const d: DummyInterface = {} as DummyInterface;
console.log(d);

The following output shows the empty object. Reading either name or age returns undefined.

{}
TypeScript