5 ms·
I was really hoping optional chaining would be in, but turns out that's scheduled for the next minor release, 3.7. The generator improvements are appreciated,
by AgentME 7y ago
I was really hoping optional chaining would be in, but turns out that's scheduled for the next minor release, 3.7.
The generator improvements are appreciated, though I wish it went even further and supported uses like redux-saga better (so the return type of a yield expression could depend on the type of the value that was yielded).
- lf-non 7y agoYeah, this is something I had hoped for as well. Mobx-state-tree [1] also makes use of generators for asynchronous tasks and typescript's inability to infer types of values returned from a yield is a pain. But fortunately, atleast in this particular case the usage semantics are really close to async/await so I have had success using a babel macro [2][3] to transform async functions to generators which restores type-safety. This is of-course a hack but has proven to work fairly well in practice. [1] https://github.com/mobxjs/mobx-state-tree https://github.com/mobxjs/mobx-state-tree [2] https://github.com/kentcdodds/babel-plugin-macros https://github.com/kentcdodds/babel-plugin-macros [3] https://github.com/ts-delight/async-to-generator.macro https://github.com/ts-delight/async-to-generator.macro
- veidr 7y agoOh, it's good to hear that feature is coming in 3.7! That's something I really miss on a regular basis. Where did you learn it's scheduled for 3.7?
- city41 7y agohttps://github.com/microsoft/TypeScript/issues/16#issuecomment-515160784 https://github.com/microsoft/TypeScript/issues/16#issuecomme...