Introduction

If you’re a Mr(s). Know It All and want to tell the compiler what to do you can use Type Assertions.

Syntax

interface Foo {
    bar: number;
    bas: string;
}
 
var foo = {} as Foo;
foo.bar = 123;
foo.bas = 'hello';