Monday, September 25, 2017

TypeScript error–Property ‘assign’ does not exists on type ‘ObjectConstructor’

A colleague asked me for help when he got into trouble with his TypeScript code. Here is a simplified version:

Although this looks like valid code, the TypeScript compiler complained:

image

After some headscratching, we discovered that there was a “rogue” tsconfig.json at a higher level that set “ES5” as the target. Object.Assign was added as part of “ES6” explaining why TypeScript complained.

image

After changing the target to “es6”, the error disappeared.

No comments: