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

Macro doesn't seem to do anything #459

Open
OnkelTem opened this issue Mar 2, 2021 · 2 comments
Open

Macro doesn't seem to do anything #459

OnkelTem opened this issue Mar 2, 2021 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@OnkelTem
Copy link

OnkelTem commented Mar 2, 2021

import { select } from 'typed-redux-saga/macro';

const getToken = (state: RootState) => state.user.account?.token; // type: (...) => string | undefined

function* fetchAlertsSaga() {
  const token = yield select(getToken); 
  // TypeScript error here 
  // TS7057: 'yield' expression implicitly results in an 'any' type because 
  //   its containing generator lacks a return-type annotation.
  // ...
}

babel-plugin-macros is installed via react-scripts dependencies:

@...
├─┬ [email protected]
│ └─┬ [email protected]
│   └── [email protected] deduped
└─┬ [email protected]
  └── [email protected]

What I do wrong? Should I configure macro somehow?

If I switch import of typed-redux-saga/macro to the typed-redux-saga and add '*' to the yields, the correct type is inferred:

  const token = yield* select(getToken);  // string | undefined
@xitox97
Copy link

xitox97 commented Apr 26, 2021

I also having this issue.

@Bohooslav
Copy link

I am also having this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants