Answer the question
In order to leave comments, you need to log in
Typescript: Do I need to import all types associated with an imported interface?
export interface IFoo {
bar: TBar[]
}
type TBar = {
a: string;
b: number;
}
IFoo
, do I need to import also TBar
? TBar
, until you import TBar
.
Answer the question
In order to leave comments, you need to log in
If you yourself use an identifier of the TBar type, then you need to import it, do not use it, i.e. for example write like this:
const foo: IFoo = {
bar: [
{a: "white", b: 10},
{a: "black", b: 20}
]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question