Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in latest release? (when upgrading from 1.4 to 1.5) #677

Open
osmestad opened this issue Dec 7, 2022 · 4 comments
Open

Regression in latest release? (when upgrading from 1.4 to 1.5) #677

osmestad opened this issue Dec 7, 2022 · 4 comments

Comments

@osmestad
Copy link

osmestad commented Dec 7, 2022

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:

  function handleArgumentThatIsPartOfUnion(requestId: 27 | 28) {
    return 22;
  }
  yield* Effects.call(handleArgumentThatIsPartOfUnion, 27);

This code works in 1.4 but in 1.5 the argument to the function called (27) gets interpreted as number (instead of that specific number it seems?)

Has anyone else had this problem? ideas to fix it?

@stengard
Copy link

stengard commented Jan 25, 2023

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

@kevich
Copy link

kevich commented Mar 26, 2023

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'});

@yvoychuk
Copy link

yvoychuk commented May 8, 2023

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.

@osmestad
Copy link
Author

We have had to stay on 1.4 to avoid these issues :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants