TypeScript: subtipo de referencia de definición de tipo (interfaz)
Estoy usando el siguiente tipo en mi TypScript:
interface ExerciseData {
id : number;
name : string;
vocabulary : {
from : string;
to : string;
}[];
}
Ahora me gustaría crear una variable que sea del mismo tipo que el atributovocabulary
, intentando lo siguiente:
var vocabs : ExerciseData.vocabulary[];
Pero eso no está funcionando. ¿Es posible hacer referencia a un subtipo de alguna manera? ¿O tendría que hacer algo como esto?
interface ExerciseData {
id : number;
name : string,;
vocabulary : Vocabulary[];
}
interface Vocabulary {
from : string;
to : string;
}
var vocabs : Vocabulary[];
Muchas gracias por pistas.