Categories
TypeScript Answers

How to fix the “property ‘assign’ does not exist on type ‘ObjectConstructor'” error with TypeScript?

Spread the love

Sometimes, we want to fix the "property ‘assign’ does not exist on type ‘ObjectConstructor’" error with TypeScript.

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

How to fix the "property ‘assign’ does not exist on type ‘ObjectConstructor’" error with TypeScript?

To fix the "property ‘assign’ does not exist on type ‘ObjectConstructor’" error with TypeScript, we should add 'es6' to compilerOptions.lib in tsconfig.json.

For instance, we write

{
  //...
  "compilerOptions": {
    "lib": ["es5", "es6", "dom", "es2015.collection"]
  }
  //...
}

to add "es6" to compilerOptions.lib in tsconfig.json so that the TypeScript compiler knows that the Object.assign method that comes with ES6 is available for use in our project.

Conclusion

To fix the "property ‘assign’ does not exist on type ‘ObjectConstructor’" error with TypeScript, we should add 'es6' to compilerOptions.lib in tsconfig.json.

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 *