Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
array(
s = { maxIndex: 2, options: [1, 2] },
a: AddArrayControlAction | RemoveArrayControlAction,
) {
switch (a.type) {
case AddArrayControlAction.TYPE: {
const maxIndex = s.maxIndex + 1;
const options = [...s.options];
// tslint:disable-next-line:no-unnecessary-type-assertion
options.splice(a.index!, 0, maxIndex);
return {
maxIndex,
options,
};
}
case RemoveArrayControlAction.TYPE: {
const options = [...s.options];
// tslint:disable-next-line:no-unnecessary-type-assertion
options.splice(a.index!, 1);
return {
...s,