Categories
TypeScript Answers

How to fix the “Property does not exist on type ‘{}'” error with TypeScript?

Spread the love

Sometimes, we want to fix the "Property does not exist on type ‘{}’" error with TypeScript.

In this article, we’ll look at how to fix the "Property does not exist on type ‘{}’" error with TypeScript.

How to fix the "Property does not exist on type ‘{}’" error with TypeScript?

To fix the "Property does not exist on type ‘{}’" error with TypeScript, we can set the variable causing the error to any type.

For instance, we write

const bar: any = {};
bar.foo = "foobar";

to set the bar variable to the any type.

Then we can do anything we want with bar.

Conclusion

To fix the "Property does not exist on type ‘{}’" error with TypeScript, we can set the variable causing the error to any type.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *