Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function numberString(x: number, y: string) {
return { type: "numberString", x, y };
}
// ok
const callEffect: Effect = Effects.call(zeroArg);
// ok
Effects.call(string, "one");
// ok
Effects.call(numberString, 1, "two");
// $ExpectError
Effects.call(string, 1);
// $ExpectError
Effects.call(string, 1);
// ok
Effects.call(string, "one", "two");
//
// Effects.promise
//
function asyncActionCreator(x: string, y: number) {
return Promise.resolve({
type: "asyncAction",
x,
y
//
// Effects.lift
//
function nestedAction(time: Date, action: { type: $Subtype }) {
return { type: "NESTED_ACTION", payload: action, time };
}
function nestedActionWrongArgOrder(
action: { type: $Subtype },
time: Date
) {
return { type: "NESTED_ACTION", payload: action, time };
}
const nestedEffect = Effects.call(zeroArg);
// ok
Effects.lift(nestedEffect, nestedAction, new Date());
// $ExpectError
Effects.lift(nestedEffect, nestedActionWrongArgOrder, new Date());
});
}
// ok
Effects.promise(asyncActionCreator, "one", 2);
// $ExpectError
Effects.promise(asyncActionCreator, 1, "two");
//
// Effects.batch
//
// ok
Effects.batch([
Effects.call(zeroArg),
Effects.promise(asyncActionCreator, "one", 2)
]);
//
// Effects.lift
//
function nestedAction(time: Date, action: { type: $Subtype }) {
return { type: "NESTED_ACTION", payload: action, time };
}
function nestedActionWrongArgOrder(
action: { type: $Subtype },
time: Date
) {
return { type: "NESTED_ACTION", payload: action, time };
const callEffect: Effect = Effects.call(zeroArg);
// ok
Effects.call(string, "one");
// ok
Effects.call(numberString, 1, "two");
// $ExpectError
Effects.call(string, 1);
// $ExpectError
Effects.call(string, 1);
// ok
Effects.call(string, "one", "two");
//
// Effects.promise
//
function asyncActionCreator(x: string, y: number) {
return Promise.resolve({
type: "asyncAction",
x,
y
});
}
// ok
Effects.promise(asyncActionCreator, "one", 2);
return { type: "zeroArg" };
}
function string(x: string) {
return { type: "string", x };
}
function numberString(x: number, y: string) {
return { type: "numberString", x, y };
}
// ok
const callEffect: Effect = Effects.call(zeroArg);
// ok
Effects.call(string, "one");
// ok
Effects.call(numberString, 1, "two");
// $ExpectError
Effects.call(string, 1);
// $ExpectError
Effects.call(string, 1);
// ok
Effects.call(string, "one", "two");
//
// Effects.promise
//
function string(x: string) {
return { type: "string", x };
}
function numberString(x: number, y: string) {
return { type: "numberString", x, y };
}
// ok
const callEffect: Effect = Effects.call(zeroArg);
// ok
Effects.call(string, "one");
// ok
Effects.call(numberString, 1, "two");
// $ExpectError
Effects.call(string, 1);
// $ExpectError
Effects.call(string, 1);
// ok
Effects.call(string, "one", "two");
//
// Effects.promise
//
function asyncActionCreator(x: string, y: number) {
return Promise.resolve({