Is there a way to call `fetch().finally()` in TypeScript?

Viewed 29

My goal is to do fetch().then().catch().finally(). I use

The problem is that the Visual Studio Code's Editor Language for TypeScript does not allow me to do so. I don't install any extension related to TypeScript, it's just there.

Then, I found the interface using the Go to Definition feature. The Promise<T> interface in lib.es5.d.ts. It does not contain finally().

1 Answers

Your compilation target has to be ES2018 or later.

Promise.prototype.finally was introduced in ES2018.

Playground

Related