How excess property check helps?

What is the purpose of excess property check, in second case?

It correctly detects bugs (as shown in this case, the misspelling of color) without creating too many false positives.

Because the object isn’t aliased anywhere else, TypeScript can be fairly confident that the excess property isn’t going to be used for a different purpose in some other part of the code. The same cannot be said of myObj – we may be inspecting it only for its .width here but then using its .colour in some other place.

Leave a Comment