Greetings We have TypeScript 1.8
I write this:
var v: Object; v = {name1: 'val1'} Everything compiles well. It seems like Object is compatible with any object. I write like this:
interface MyInterface { name2: string; } var v: MyInterface; v = {name1: 'val1', name2: 'val2'} // <--- РУГАЕТСЯ And he scolds: Error: (138, 55) TS2322: Type '{name1:' val1 ', name2:' val2 '}' is not assignable to type 'MyInterface'. Object literal may not specify the type of myInterface.
BUT! If only "known properties", then why not swear at the first option with Object? After all, in lib.d.ts, Object is also defined as an Interface:
interface Object {... And, of course, no name1 is described there either.