Re:TypeScript 2.3
by ng12 on Thursday April 27, 2017 @02:51PM
(#14213816)
Er, I'm looking at it right now? I don't know what to tell you.
And if I add the type parameter to the constructor...
Re: your edit, you actually don't need that first typing. Typescript will infer the type of the promisedString.
[ Parent
| on HN ]
Re:TypeScript 2.3
by andreypopp on Thursday April 27, 2017 @02:56PM
(#14213850)
> your edit, you actually don't need that first typing. Typescript will infer the type of the promisedString
Ok, but still this is confusing, it can't infer the type of RHS given the annotated LHS? Intuitively there's nothing wrong with it and Flow does that well...
Re:TypeScript 2.3
by mcintyre1994 on Thursday April 27, 2017 @04:31PM
(#14214443)
Note this is similar to c# (and thinking about it, every OO language I can think of):
var cat = new Animal<Cat>(...); // yup! Animal<Cat> cat = new Animal(...); // Nope
I wonder if internally ts is treating these generic-accepting classes in the same way, where the generic is required?