I have an ember component that imports an enum type like this:
import { StateNames, CardSummary } from '../../types/snowcat/state-types'
the type file is as follows:
export enum CardState {
error = 'error',
new = 'new',
okay = 'okay',
warning = 'warning',
}
Then I use the enumeration as follows in the component:
@computed('cardSummary.cardState')
get type(): string {
if ([CardState.new, CardState.okay, CardState.warning].includes(this.cardSummary.cardState)) {
return 'info'
}
return 'error'
}
Everything seems good with the code. I don't get any TypeScript errors when creating the code, but I get a runtime error:
loader.js:247 Uncaught Error: Could not find module `types/snowcat/state-types` imported from `snowcat/models/certificate`
at missingModule (loader.js:247)
at findModule (loader.js:258)
at Module.findDeps (loader.js:168)
at findModule (loader.js:262)
at requireModule (loader.js:24)
at r (loader.js:176)
at ember-data.js:39
at Array.forEach (<anonymous>)
at getDsModels (ember-data.js:36)
at getModels (ember-data.js:66)
What's happening? How to fix it?
source
share