Say you have an interface called Album and a function called printAlbumDetails that takes one parameter of type Album.

interface Album { name: string; artist: string; id: string; year: number; } function printAlbumDetails(album: Album) { console.log(`The album ${album.name} was created by ${album.artist} in the year ${album.year}`); } 

You would expect the first function call to work and the second to have an error because of the extra property genre

const vessel: Album = { name: 'Vessel', artist: 'Twenty One Pilots', id: '119', year: 2013 } // will throw no error printAlbumDetails(vessel); const scaledAndIcy = { name: 'Scaled and Icy', artist: 'Twenty One Pilots', id: '120', year: 2021, genre: 'Alternative Pop' } // also throws no error though the scaledAndIcy object has a genre property  // that doesn't exit on the Album type  printAlbumDetails(scaledAndIcy) 

This behavior is weird and it gets even weirder when I skip assigning the scaledAndIcy object to a variable and pass the object directly as a parameter

printAlbumDetails({ name: 'Scaled and Icy', artist: 'Twenty One Pilots', id: '120', year: 2021, genre: 'Alternative Pop' // Error on the genre property saying "Object literal may only  // specify known properties, and 'genre' does not exist in type  // 'Album'." }); 

What is happening?

When you assign an object to a variable and pass that variable as a function parameter that expect certain properties to be present, Typescript confirms that those properties are present and it ignores other additional properties in the object. The reason for this is because Typescript assumes that you might use the object elsewhere and those additional properties are useful so it allows you to keep them.

To avoid this behavior, specify the type the object should be when assigning it to a variable and then Typescript will enforce the 'known properties only' rule.

These types of objects are called closed objects. By default, all objects are open, that is, Typescript does not mind the availability of additional properties.

You make an object closed by either specifying a type the object should be during variable assignment or inlining the object.

Inlining the object means passing an object straight to a function as a parameter instead of assigning it to a variable first. When this happens, Typescript knows that that object cannot be used anywhere else and so it discerns that the additional properties do not have a reason to exist.

Voila! This explains why this code-block below

printAlbumDetails({ name: 'Scaled and Icy', artist: 'Twenty One Pilots', id: '120', year: 2021, genre: 'Alternative Pop' // Error on the genre property saying "Object literal may only  // specify known properties, and 'genre' does not exist in type  // 'Album'." }); 

gave an error. Since the object is inlined, Typescript ensures no additional properties exist on the object as they cannot be used anywhere else.