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
.