3 ms·
Er, I'm looking at it right now? I don't know what to tell you. error TS2322: Type 'Bluebird<{}>' is not assignable to type 'Bluebird<string>'. And if I ad
by ng12 10y ago
Er, I'm looking at it right now? I don't know what to tell you.
error TS2322: Type 'Bluebird<{}>' is not assignable to type 'Bluebird<string>'.
And if I add the type parameter to the constructor...
error TS2345: Argument of type '42' is not assignable to parameter of type 'string | Thenable<string>'
Re: your edit, you actually don't need that first typing. Typescript will infer the type of the promisedString.
- andreypopp 10y ago> 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...
- mcintyre1994 10y agoNote 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?