Hacker News new | ask | show | jobs
by Cpoll 1523 days ago
> function getData() { return fetch(…); }

I feel like there are advantages to making it `async function`, even if it's superfluous, because it signals to readers and to static code analysis that the function returns a promise. That's assuming the return type of fetch(...) can't be inferred by static analysis and developer tooling.

1 comments

> the type of fetch() can't be inferred by static analysis

That is preposterous.

It's not. One might assume it's Node fetch, but parent post was just using a specific example to make a general point. Fetch can be `any`thing.

Would you say the same thing about

function getData() { return mysteryFunction(…); }