I am not able to realize the logic behind it
The logic as I understand is the following:
Interface Thing
is a contract asking to have a (non-null, non-undefined) prop
as a string
.
If one removes the property, then the contract is not implemented anymore.
If you want it still valid when removed, just declare it as optional with a ?
: prop?: string
I'm actually surprised that this was not causing error in earlier versions of TypeScript.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…