TypeScript - Empty Type

Type Script History

There's yet another type which is quite similar: {}, the empty type. It describes an object that has no members on its own. TypeScript issues a compile-time error when you try to access arbitrary properties on such an object:

  

        // Type {}
        const obj = {};

        // Error: Property 'prop' does not exist on type '{}'.
        obj.prop = "value";
    

However, you can still use all properties and methods defined on the Object type, which are implicitly available via JavaScript's prototype chain:

  

        // Type {}
        const obj = {};

        // "[object Object]"
        obj.toString();