Open OnkelTem opened 3 years ago
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:
babel-plugin-macros
react-scripts
@... ├─┬ react-scripts@4.0.3 │ └─┬ babel-preset-react-app@10.0.0 │ └── babel-plugin-macros@2.8.0 deduped └─┬ typed-redux-saga@1.3.1 └── babel-plugin-macros@2.8.0
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:
typed-redux-saga/macro
typed-redux-saga
'*'
const token = yield* select(getToken); // string | undefined
I also having this issue.
I am also having this issue.
babel-plugin-macros
is installed viareact-scripts
dependencies:What I do wrong? Should I configure macro somehow?
If I switch import of
typed-redux-saga/macro
to thetyped-redux-saga
and add'*'
to the yields, the correct type is inferred: