If I declare let bar: Bar;
and set it to initialFooConfig;
, is bar
still considered as type Bar and an object, or does it become an object in literal notation?
If the assignment can be done both ways (assuming initialFooConfig
is not a constant), what sets apart initialFooConfig
from initialBarConfig
?
interface IFoo {
code: number;
name: string;
}
export const initialFooConfig: IFoo = {
code: 12,
name: "bar"
}
class Bar implements IFoo {
code: number;
name: string;
constructor(code: number, name: string) {
this.code = code;
this.name = name;
}
}
export const initialBarConfig = new Bar(12,"bar");