I am using typescript 1.4.1 and have the following code:
var hello: {message: string}; hello = {world: 't'};
As expected, the typescript compiler generates an error:
Type '{world: string; } 'is not assigned to type' {message: string; } ". The 'message' property is not in the type '{world: string;}". (var) hello: {message: string; }
But if the type contains only an optional property, for example:
var hello: {message?: string}; hello = {world: 't'};
Then the compiler is completely happy, but I would like the error to be detected.
What am I doing wrong? or is it a typescript error?
Thank you for your help!
source share