user3291025
user3291025

Reputation: 1117

Svelte: how to use native web APIs

In a Svelte app, how can we access native web APIs, such as the File System Access API, to, for example, use the window.showOpenFilePicker() method?

Upvotes: 1

Views: 1501

Answers (1)

tiberriver256
tiberriver256

Reputation: 539

To get Typescript support for the new WICG File System Access APIs you'll need to make the following two changes:

  1. Install the @types/wicg-file-system-access npm package into your dev dependencies (i.e., for npm npm install --save-dev @types/wicg-file-system-access).
  2. Add the types to your tsconfig.json file
{
  ...
  "compilerOptions": {
    "types": ["@types/wicg-file-system-access"]
  }
  ...
}

Upvotes: 9

Related Questions