Open osmestad opened 1 year ago
I think this is related:
import { call } from "typed-redux-saga";
interface DownloadFileProgress {
onDownloadProgress: (data: { total: number; loaded: number }) => void;
}
export const downloadAudioFile = function* (
fileId: string,
{ onDownloadProgress }: Partial<DownloadFileProgress>
) {
// download file
};
function* test() {
yield* call(downloadAudioFile, "some-id", {
// total and loaded is any
onDownloadProgress: ({ total, loaded }) => {
}
});
}
in 1.5
the parameters of onDownloadProgress
is inferred as any
in 1.4
it works as expected, loaded
and total
is number
.
https://codesandbox.io/s/billowing-water-vlnhey?file=/src/index.ts
Hello everyone! I still think there is some regression with string literals:
import { call } from 'typed-redux-saga';
import { SagaIterator } from 'redux-saga';
type StringLiteral = 'GET' | 'POST' | 'PUT' | 'DELETE';
type ObjectWithLiteral = {
method: StringLiteral,
};
function simpleOne(object: ObjectWithLiteral): StringLiteral {
return object.method;
}
function* generator(object: ObjectWithLiteral): SagaIterator<StringLiteral> {
return object.method;
}
function* test(): SagaIterator<void> {
// shows error
const a = yield* call(simpleOne, {method: 'GET'});
// shows error
const b = yield* call(generator, {method: 'GET'});
}
// do not show error, which is correct behaviour according to latest typescript
simpleOne({method: 'GET'});
I have the same problem (version 1.5) - I'm using untyped call
as a workaround. It would be nice to find fix for this issue.
We have had to stay on 1.4
to avoid these issues :-(
Hi,
I added a PR with two examples of cases that started failing for us when trying to apply the update: #675
The smallest case looks like this:
This code works in 1.4 but in 1.5 the argument to the function
call
ed (27) gets interpreted as number (instead of that specific number it seems?)Has anyone else had this problem? ideas to fix it?