I'm using typescript 1.4.1 and have the following code:
var hello: {message: string};
hello = {world: 't'};
As intended, the typescript compiler outputs an error:
Type '{ world: string; }' is not assignable to type '{ message: string; }'. Property 'message' is missing in type '{ world: string; }'. (var) hello: { message: string; }
But if the type contains only an optional property such as in:
var hello: {message?: string};
hello = {world: 't'};
Then the compiler is perfectly happy, but I would like the error to be detected.
What am'I doing wrong? or is it a typescript bug?
Thanks for your help!