This week, a colleague asked me to have a look at his code. He was working on a web project with some TypeScript code but the moment he opened the project hundreds of errors appeared. We discovered that he recently upgraded to TypeScript 1.6 and in this version the object checking rules became more strict:
Before TypeScript 1.6 you could do something like this:
Note that although the interface only defines 3 properties, the compiler doesn’t complain when I add an extra property to my object literal.
In TypeScript 1.6 this is no longer the case, and an error is thrown when you add a property that is not part of the interface:
You can suppress this error by passing the --suppressExcessPropertyErrors compiler option.
More information in the following GitHub issue: https://github.com/Microsoft/TypeScript/issues/3755