New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate how to support const app = fastify(); await app;
in TypeScript
#2378
Comments
@Ethan-Arrowood Could you explain why wouldn't it work? You can await anything in JS/TS, not just promises - it'll just return the awaited value. So, given the above, this compiles/works just fine: import * as fastify from "fastify";
const _app = fastify.fastify()
const app = await _app; I also see no use for this |
The fastify instance is a Thenable, it implements a |
Understandable, but if I'm not mistake, this issue is specific to the |
This is really a great point @Ethan-Arrowood and I somehow agree with you. |
@Ethan-Arrowood correct me if I'm wrong but can't we use types union? See #2428 |
Related to #2376
See the test in the PR.
How do we type this behavior?
If its not possible (which I sorta expect but don't know for sure), then we should provide some type-cast option like:
The text was updated successfully, but these errors were encountered: