One potential issue is with a model that may be in an incorrect state, where we can examine the errors using model.getErrors()
. These errors are stored in a map that includes keys of a certain type keyof D
, as well as a special key called base
.
Why does this apparently valid code fail to compile? Check out the TypeScript Playground
export type Errors<D> = {
readonly [K in (keyof D | 'base')]?: string[]
}
class Model<D> {
getErrors(): Errors<D> {
return { base: ['some base error'] }
}
}