Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const valid2: ActionOn = actionOn(
actions => actions.doThunkString,
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid2: ActionOn = actionOn(
actions => actions.doThunkNumber,
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid3: ActionOn = actionOn(
() => 'ADD_TODO',
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid3: ActionOn = actionOn(
// typings:expect-error
() => 1,
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid4: ActionOn = actionOn(
doThunkString: Thunk;
doActionNumber: Action;
doThunkNumber: Thunk;
}
interface OtherModel {
otherAction: Action;
otherThunk: Thunk;
}
interface StoreModel {
listening: ListeningModel;
other: OtherModel;
}
const valid1: ActionOn = actionOn(
actions => actions.doActionString,
(state, target) => {
const [foo] = target.resolvedTargets;
foo + 'bar';
target.type + 'foo';
if (target.error != null) {
target.error.stack;
}
state.logs.push(target.payload);
},
);
const invalid1: ActionOn = actionOn(
actions => actions.doActionNumber,
(state, target) => {
// typings:expect-error
() => 'ADD_TODO',
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid3: ActionOn = actionOn(
// typings:expect-error
() => 1,
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid4: ActionOn = actionOn(
// typings:expect-error
() => undefined,
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
const valid4: ActionOn = actionOn(
actions => [actions.doActionString, actions.doThunkString],
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid5: ActionOn = actionOn(
const invalid1: ActionOn = actionOn(
actions => actions.doActionNumber,
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid2: ActionOn = actionOn(
actions => actions.doThunkString,
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid2: ActionOn = actionOn(
actions => actions.doThunkNumber,
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid3: ActionOn = actionOn(
() => 'ADD_TODO',
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid3: ActionOn = actionOn(
// typings:expect-error
const invalid2: ActionOn = actionOn(
actions => actions.doThunkNumber,
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid3: ActionOn = actionOn(
() => 'ADD_TODO',
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid3: ActionOn = actionOn(
// typings:expect-error
() => 1,
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid4: ActionOn = actionOn(
// typings:expect-error
() => undefined,
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
if (target.error != null) {
target.error.stack;
}
state.logs.push(target.payload);
},
);
const invalid1: ActionOn = actionOn(
actions => actions.doActionNumber,
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid2: ActionOn = actionOn(
actions => actions.doThunkString,
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid2: ActionOn = actionOn(
actions => actions.doThunkNumber,
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid3: ActionOn = actionOn(
() => 'ADD_TODO',
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid4: ActionOn = actionOn(
// typings:expect-error
() => undefined,
// typings:expect-error
(state, target) => {
state.logs.push(target.payload);
},
);
const valid4: ActionOn = actionOn(
actions => [actions.doActionString, actions.doThunkString],
(state, target) => {
state.logs.push(target.payload);
},
);
const invalid5: ActionOn = actionOn(
actions => [actions.doActionString, actions.doThunkNumber],
(state, target) => {
// typings:expect-error
state.logs.push(target.payload);
},
);
const valid5: ActionOn = actionOn(
actions => [actions.doActionString, actions.doThunkNumber],
.map(getStoreActions().lightning.getAllInfo),
);
}
const nodesData = getStoreState().lightning.nodes;
const { allCharts } = getState();
// sync the chart with data from all of the nodes
const chart = updateChartFromNodes(allCharts[network.id], network, nodesData);
actions.setAllCharts({
...allCharts,
[network.id]: chart,
});
actions.redrawChart();
},
),
onNetworkSetStatus: actionOn(
(actions, storeActions) => storeActions.network.setStatus,
(state, { payload }) => {
const { id, status, only, all = true } = payload;
const chart = state.allCharts[id];
if (only) {
// only update a specific node's status
chart.nodes[only].properties.status = status;
} else if (all) {
// update all node statuses
Object.keys(chart.nodes).forEach(
name => (chart.nodes[name].properties.status = status),
);
}
},
),
removeLink: action((state, linkId) => {
if (typeof target.payload === 'string') {
state.logs.push(target.payload);
} else {
target.payload + 10;
}
},
);
const valid6: ActionOn = actionOn(
() => ['foo', 'bar'],
(state, target) => {
state.logs.push(target.payload);
},
);
const valid7: ActionOn = actionOn(
() => 'foo',
(state, target) => {
state.logs.push(target.payload);
},
);
state.logs.push(target.payload);
},
);
const valid5: ActionOn = actionOn(
actions => [actions.doActionString, actions.doThunkNumber],
(state, target) => {
if (typeof target.payload === 'string') {
state.logs.push(target.payload);
} else {
target.payload + 10;
}
},
);
const valid6: ActionOn = actionOn(
() => ['foo', 'bar'],
(state, target) => {
state.logs.push(target.payload);
},
);
const valid7: ActionOn = actionOn(
() => 'foo',
(state, target) => {
state.logs.push(target.payload);
},
);