TypeScript: subtipo de referência da definição de tipo (interface)
Estou usando o seguinte tipo no meu TypScript:
interface ExerciseData {
id : number;
name : string;
vocabulary : {
from : string;
to : string;
}[];
}
Agora eu gostaria de criar uma variável do mesmo tipo que o atributovocabulary
, tentando o seguinte:
var vocabs : ExerciseData.vocabulary[];
Mas isso não está funcionando. É possível fazer referência a um subtipo de alguma forma? Ou eu teria que fazer algo assim?
interface ExerciseData {
id : number;
name : string,;
vocabulary : Vocabulary[];
}
interface Vocabulary {
from : string;
to : string;
}
var vocabs : Vocabulary[];
Muito obrigado pelas dicas.