async
関数のreturn typeにvoid
を定義した。
const someFunc = async (): void => { await someMethod() }
TypeScriptに叱られる。
Type 'void' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value
こう書く。
const someFunc = async (): Promise<void> => { await someMethod() }
stringやオブジェクトを返したいなら。
const someFunc = async (): Promise<string> => { await someMethod() } type Props = { ~ } const someFunc = async (): Promise<Props> => { await someMethod() }