3 ms·
This: > add .await after every function call, and then remove it again wherever the compiler complains Should be something Rust (and JS runtimes!) should some
by ojosilva 3y ago
This:
> add .await after every function call, and then remove it again wherever the compiler complains
Should be something Rust (and JS runtimes!) should somehow check/complain. It's just too easy to forget to await on a function returning a Future/Promise. Rust at least will complain if the returning types don't match some expected value and hint a helpful "help: consider `await`ing on the `Future`". Typescript, well tslint, has "no-floating-promises" which is also helpful.
- MuffinFlavored 3y ago> It's just too easy to forget to await on a function returning a Future/Promise. Is there not a way with linting configurations to bump this warning to a "compile time error" (unless marked ignore or something)?
- eddd-ddde 3y agoYes now a days every sensible project comes with a linter by default that will tell you when you are using a promise wrong.
- icambron 3y agoThat seems extreme. In both JS and Rust, it’s not unusual to not await the promise/future immediately and just deal with the returned promise directly. Presumably that’s why neither language awaits for you automatically. I would be pretty annoyed if the linter yelled at me every time I did that.