Back to the Seattle Mariners Newsfeed

Property does not exist on type '{}' in TypeScript [Solved] | bobbyhadz (2024)

The "Property does not exist on type '{}'" error occurs when we try to accessor set a property that is not contained in the object's type.

To solve the error, type the object properties explicitly or use a type withvariable key names.

Here is an example of how the error occurs:

index.ts

Copied!

const obj = {};// u26d4ufe0f Error: Property 'name' does not exist on type '{}'.ts(2339)obj.name = 'Bobby Hadz';

You might also get the error if you use the Object type.

index.ts

Copied!