Is there a way to include an enum in an interface while avoiding issues with using the interface elsewhere? (specifically in typescript 2.5) Let's take a look at some sample code:
allEnums.ts
export enum ButtonType {
Top = 1,
Bottom = 2
}
// other enums can be added here
buttonInterface.d.ts
import { ButtonType } from "allEnums";
interface ButtonInterface {
buttonType: ButtonType
}
formInterface.d.ts
interface FormInterface {
buttons: ButtonInterface[]
}
The issue arises when trying to use the interface in formInterface.d.ts
Cannot find name 'ButtonInterface'
To resolve this, we can import the ButtonInterface into the FormInterface like so:
import { ButtonInterface } from "buttonInterface";
However, importing Interfaces may not be the best solution for this situation.