Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'showSaveFilePicker' does not exist on type 'Window & typeof globalThis'

const opts = {
      suggestedName: 'data',
      types: [
        {
          description: 'NewCSV',
          accept: { 'text/csv': ['.csv'] },
        },
      ],
    };
    const handle = await (window).showSaveFilePicker(opts);

now I have the type error Property 'showSaveFilePicker' does not exist on type 'Window & typeof globalThis', providing type as any solves the issue of type error.

const handle = await (<any>window).showSaveFilePicker(opts);

But still it will show the eslint error Unsafe call of an any typed value. So the only solution I know is to disable eslint for the file. Is there any other way to avoid both the type error and eslint error ?

like image 808
mason Avatar asked Sep 09 '25 17:09

mason


2 Answers

It seems like TypeScript's type definitions for the file system access API are currently broken: https://github.com/microsoft/vscode/issues/141908

For now, try installing the package @types/wicg-file-system-access to fix the types:

# Yarn
yarn add --dev @types/wicg-file-system-access

# NPM
npm install --save-dev @types/wicg-file-system-access

You will also need to update the types field of the tsconfig.json with:

  "compilerOptions": {
    "types": [ "@types/wicg-file-system-access"]
   }
like image 171
Merlin04 Avatar answered Sep 12 '25 11:09

Merlin04


had to npm i @types/wicg-file-system-access in my Angular project home directory.

like image 43
Julien Avatar answered Sep 12 '25 11:09

Julien