wixplosives / engine

Scalable Web Application Engine

Home Page:https://wixplosives.github.io/engine/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AsyncApi inferring types strangely

Zombiefruit opened this issue · comments

Here's a stripped down example: here.

Not sure exactly what is happening here, but something seems to be getting lost in translation.

new Promise(() => false)?
you mean Promise.resolve(false)?

new Promise(() => false)?
you mean Promise.resolve(false)?

I don't know what's wrong with me, I keep thinking I can do this. Anyhow, Promise.resolve(false) works but new Promise((res) => res(false)) doesn't.

If you use new Promise, you need to give it an explicit type parameter- new Promise<boolean>.
There's a separate bug in the inference there, where it infers Promise<false> | Promise<true>. So that's probably a bug.

Ah, makes sense. Okay, closing.

there's the separate issue... I'll have a PR soon