funkia / turbine

Purely functional frontend framework for building web applications
MIT License
685 stars 27 forks source link

Lack of generator return type inference #105

Open deklanw opened 5 years ago

deklanw commented 5 years ago

Just noticed this while looking through the examples. Turns out it's a Typescript limitation which is going to be fixed soon (hopefully):

https://github.com/microsoft/TypeScript/issues/2983 https://github.com/Microsoft/TypeScript/issues/30555

Just making an issue for it in anticipation.

Jomik commented 5 years ago

We do sort of fix this issue with our own typescript compiler plugin. https://github.com/funkia/go-notation

paldepind commented 5 years ago

Unfortunately, I don't think any of the new features in TypeScript addresses this issue. As far as i can tell, even with the planned improvements the yield keyword will still always results in any :sob:

deklanw commented 5 years ago

@Jomik Thanks I'll try that out

@paldepind I didn't look hard into the TS issue. Why will these changes not help?

Jomik commented 5 years ago

All the yield statements will still return any with the typescript update, so we can still not infer or typecheck the return value, so it does not help that much.

deklanw commented 5 years ago

I read more properly about generators/iterators and I understand better now. In case it helps someone else: it's because in general there is no connection between the Next type and Yield type.

Although, https://github.com/microsoft/TypeScript/pull/30790#issuecomment-480550228