Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object literal may only specify known properties, and types does not exist in type: #57

Open
linonetwo opened this issue May 2, 2023 · 1 comment

Comments

@linonetwo
Copy link

linonetwo commented May 2, 2023

In example in readme

      const fileHandle = await showSaveFilePicker({
        _preferPolyfill: false,
        suggestedName: 'Untitled.png',
        types: [
          { accept: { 'image/png': ['png'] } },
          { accept: { 'image/jpg': ['jpg'] } },
          { accept: { 'image/webp': ['webp'] } },
        ],
        excludeAcceptAllOption: false, // default
      });

      // Look at what extension they chosen
      const extensionChosen = fileHandle.name.split('.').pop();

      const blob = {
        jpg: generateCanvasBlob({ type: 'blob', format: 'jpg' }),
        png: generateCanvasBlob({ type: 'blob', format: 'png' }),
        webp: generateCanvasBlob({ type: 'blob', format: 'webp' }),
      }[extensionChosen];

      await blob.stream().pipeTo(fileHandle.createWritable());
      // or
      const writer = await fileHandle.createWritable();
      await writer.write(blob);
      await writer.close();

Error in ` types: [

Argument of type '{ _preferPolyfill: false; suggestedName: string; types: ({ accept: { 'image/png': string[]; }; } | { accept: { 'image/jpg': string[]; }; } | { accept: { 'image/webp': string[]; }; })[]; excludeAcceptAllOption: false; }' is not assignable to parameter of type '{ excludeAcceptAllOption?: boolean | undefined; accepts?: any[] | undefined; suggestedName?: string | undefined; _name?: string | undefined; _preferPolyfill?: boolean | undefined; }'.
Object literal may only specify known properties, and 'types' does not exist in type '{ excludeAcceptAllOption?: boolean | undefined; accepts?: any[] | undefined; suggestedName?: string | undefined; _name?: string | undefined; _preferPolyfill?: boolean | undefined; }'.ts(2345)

"native-file-system-adapter": "^3.0.0",

@linonetwo
Copy link
Author

Also in showOpenFilePicker

      const [fileHandle] = await showOpenFilePicker({
        _preferPolyfill: false,
        multiple: false,
        excludeAcceptAllOption: true,
        types: [
          {
            description: 'JSON file',
            accept: {
              'application/json': ['.json'],
            },
          },
        ],
      });

Argument of type '{ _preferPolyfill: false; multiple: false; excludeAcceptAllOption: true; types: { description: string; accept: { 'application/json': string[]; }; }[]; }' is not assignable to parameter of type '{ multiple?: boolean | undefined; excludeAcceptAllOption?: boolean | undefined; accepts?: any[] | undefined; _preferPolyfill?: boolean | undefined; }'.
Object literal may only specify known properties, and 'types' does not exist in type '{ multiple?: boolean | undefined; excludeAcceptAllOption?: boolean | undefined; accepts?: any[] | undefined; _preferPolyfill?: boolean | undefined; }'.ts(2345)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant