Add typings condition operators for Action class (#1909)

This commit is contained in:
Stefan Hall
2023-11-16 06:18:06 +13:00
committed by GitHub
parent fecc9178b3
commit f970263c72
3 changed files with 12 additions and 4 deletions

View File

@@ -318,7 +318,7 @@ describe('Action', () => {
}).toThrow(/invalid field/i);
expect(() => {
new Action('noop', 'name', 'James', null, fieldTypes);
new Action(null, 'name', 'James', null, fieldTypes);
}).toThrow(/invalid action operation/i);
});
});

View File

@@ -416,17 +416,19 @@ export class Condition {
}
}
let ACTION_OPS = ['set', 'link-schedule'];
type ActionOperator = 'set' | 'link-schedule';
let ACTION_OPS: ActionOperator[] = ['set', 'link-schedule'];
export class Action {
field;
op;
op: ActionOperator;
options;
rawValue;
type;
value;
constructor(op, field, value, options, fieldTypes) {
constructor(op: ActionOperator, field, value, options, fieldTypes) {
assert(
ACTION_OPS.includes(op),
'internal',

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [Marethyu1]
---
Type hardening action operator in rules.tsx