Well, when I started with Angular I came in touch with Typescript the first time - and I did a huge mistake: I used always any as datatype.
So now I have a few 10.000 lines of code and want to make it "type-save". Better late then never... and here comes the problem:
I have an object that has a property validity with a variable number of key-values, like
obj.validity = {
time: true,
feePayed: true,
approved: true
}
or
obj.validity = {
time: true,
feePayed: true,
}
or
obj.validity = {
startpass: true,
passport: true
}
the possible keys are defined in an enum:
export enum VerificationType {
TIME = 'time',
STARTPASS = 'startpass',
PASSPORT = 'passport',
FEEPAYED = 'feePayed',
ALLOWPAYPENT = 'allowPayment',
MANUALRELEASEPAYMENT = 'manualReleasePayment',
MANUALAPPROVE = 'manualApprove',
ALLPAYED = 'allPayed',
APPROVED = 'approved',
}
In the object declaration I tried now something like that:
class obj {
validity: ISkaterValidation
}
and
export type ISkaterValidation = {
[key in VerificationType]: boolean;
};
This fails with error TS2339: Property 'ANY PROPERTY NAME' does not exist on type 'ISkaterValidation'.
I'm still a beginner with Typescript typings and hope that somebody can give me a solution, please.