I want to declare an enum in typescript
// types/types.d.ts
declare enum SectionType {
H1 = "H1",
H2 = "H2",
H3 = "H3",
H4 = "H4",
H5 = "H5",
H6 = "H6",
P = "P",
}
declare type Section = {
type: SectionType
text: string
}
declare type Page = {
slug: string
sections: Section[]
}
declare type Site = {
slug: string
pages: Page[]
}
but at runtime, when running this:
const defaultHomePage = {
slug: 'home',
sections: [
{
type: SectionType.H1,
text: 'Hello World'
}
]
}
I get an error:
Uncaught ReferenceError: SectionType is not defined
What's going wrong here?