You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the gaps in Effection is that it has some idiosyncrasies in working with TypeScript. In particular with the way TS handles generators, there is no way for the right hand side of a yield expression to influence the inferred type of the left hand side. As a result, you need to explicitly annotate your intermediate values, otherwise TS infers them as being of type any
// `bare` is typed as `any`letbare=yieldPromise.resolve(10);// to get type support you need to explicitly annotateletnum: number=yieldPromise.resolve(10);
This can be problematic since you can actually get it wrong and get the compiler out of sync with the actual code which can result in mystifying runtime errors.
// this will type-check just fineletnum: number=yieldPromise.resolve('not a number!');
The fact that there is not inference is confusing as seen here and so we should arm folks with the knowledge a) not to be suprised by it and b) how to work with it, because it's something that will likely happen very soon in their journey.
The text was updated successfully, but these errors were encountered:
It would require a new release of TypeScript, but given the response from one of the folks on the core team, they are still not sure how to approach it yet microsoft/TypeScript#38534 (comment)
I also have a prototype of Effection that works with TypeScript out of the box: /~https://github.com/cowboyd/nano but it is only a very recent discovery, and would imply some pretty major breaking changes, and so we reasonably wouldn't be able to leverage it for at least a year.
One of the gaps in Effection is that it has some idiosyncrasies in working with TypeScript. In particular with the way TS handles generators, there is no way for the right hand side of a
yield
expression to influence the inferred type of the left hand side. As a result, you need to explicitly annotate your intermediate values, otherwise TS infers them as being of typeany
This can be problematic since you can actually get it wrong and get the compiler out of sync with the actual code which can result in mystifying runtime errors.
The fact that there is not inference is confusing as seen here and so we should arm folks with the knowledge a) not to be suprised by it and b) how to work with it, because it's something that will likely happen very soon in their journey.
The text was updated successfully, but these errors were encountered: