Reputation: 921
When trying to use window.FormData
I get the following error:
The name 'FormData' does not exist in the current scope
The same happens to FileReader
Upvotes: 4
Views: 8354
Reputation: 251
add dom
to the lib
array in the tsconfig.json
of your project.
{
"compilerOptions": {
...
"lib": ["es2018", "dom"], // add `dom` to the array
...
}
}
Upvotes: 17
Reputation: 250942
You can check a feature exists using:
if (window.FormData) {
alert('Yes');
}
This relies on falsey checks - if you want to be explicit, use.
if (typeof FormData !== 'undefined') {
alert('Yes');
}
Upvotes: 1