Reputation: 185
so I'm doing a project that uses react and typescript, however I need to access some DOM variables like navigator and location. However I can access those vars in a JS file but not is TS file. I've been searching but couldn't find any answer. I hope this is not trivial.
Example of a function I called in JS but need it to be in TS:
const { usage, quota } = await navigator.storage.estimate();
Thank you in advance
Upvotes: 5
Views: 4260
Reputation: 1132
You have to add option to your tsconfig.json file.
Add dom to compilerOptions.lib array like here:
{
"compilerOptions": {
"lib": [
"dom"
]
}
}
This option will add necessary typings for DOM API.
Upvotes: 9