I have a Interface IBase and a variable that contains a few other objects (in the sample i just added base for a better demonstration)
interface IBase {
height?:number;
width?:number;
}
var element = {
base: {
}
}
How can I say that the object that the varable element.base has is from the type IBase? I know that I could create a type for the element variable that contains the types of base etc, but is that also a possibility to type that scenario without doing so.
Van den Brink's answer is good. Just as a demo another option :
var element = {
base: <IBase> {
}
}
This will give the desired intellisense as well :