The TS docs mention interfaces and type aliases, but I can't seem to find much info on importing or exporting interfaces as type
and was hoping to get some clarification:
For example an interface can be exported as:
// located in ./MyInterface.ts
export interface MyInterface
{
foo: string;
bar: () => number;
}
export type {MyInterface as MyInterfaceType}
and it can be imported as:
import {MyInterface} from "./MyInterface"
or
import type {MyInterface} from "./MyInterface"
or
import {MyInterfaceType} from "./MyInterface"
or
import type {MyInterfaceType} from "./MyInterface"
Can anyone explain the difference in behavior between each interface import?
type
s are like interfaces, except they can't be extended (but can be combined via unions) and bound to objects OR primitives? – Hymnology