Instead of creating a new interface
you can annotate anything you
want inline using :{ /*Structure*/ }
. The previous example presented again with an inline type:
var age: number = 32; // number variable var name: string = "John";// string variable var isUpdated: boolean = true;// Boolean variable var name: { first: string; second: string; }; name = { first: 'John', second: 'Doe' }; name = { // Error : `second` is missing first: 'John' }; name = { // Error : `second` is the wrong type first: 'John', second: 1337 };