Re:A one-line package broke `npm create-react-app`
by ehsankia on Saturday April 25, 2020 @01:59PM
(#22979882)
shouldn't it then be called is-promise-like? Also, if you're being loose about it anyways, can't you simply just go for `if (obj && typeof obj.then == 'function')` and call it a day? I'd say that's short enough to include your own version and not rely on a package for.
I think that module over complicates it as it is, and most people don't need that level of complication in their code.
Re:A one-line package broke `npm create-react-app`
by zbentley on Saturday April 25, 2020 @03:20PM
(#22980586)
> Perhaps if TS or an extension allowed "materializing" TS, that is `value instanceof SomeInterface` generated code to check for the existence of appropriate interface members, this could be avoided
It's not perfect and a bit of a bolt-on, but io.ts works reasonably well in this area:
Typescript partially solves that by declaring types, but if you have a any variable, you still need to do some probing to be able to safely convert it to a PromiseLike, because TypeScript goes to great lengths to not actually produce physical code on its output, attempting to be just a type checker.
Perhaps if TS or an extension allowed "materializing" TS, that is `value instanceof SomeInterface` generated code to check for the existence of appropriate interface members, this could be avoided, but alas, this is not the case.