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

Impossibility to extend meta according to TypeScript #1359

Closed
chiefGui opened this issue Mar 19, 2019 · 1 comment · Fixed by #1629
Closed

Impossibility to extend meta according to TypeScript #1359

chiefGui opened this issue Mar 19, 2019 · 1 comment · Fixed by #1629
Assignees
Labels
Bug Types Issues relating to the Typescript definition files

Comments

@chiefGui
Copy link

Hey there!

I have a dead simple snippet that actually works:

private addFilesToQueue(files: File[]): void {
  each(
    (file: File) =>
      uppy.addFile({
        name: file.name,
        type: file.type,
        data: file,
        meta: {
          path: file.path
        }
      }),
    files
  );
}

Turns out that TypeScript complains when adding path to meta and I'd love to understand exactly why or whether this is expected or not.

Here goes the message:

image

Transcription:

(parameter) file: File
Type '{ path: any; }' is not assignable to type '{ name: string; type?: string | undefined; }'.
Object literal may only specify known properties, and 'path' does not exist in type '{ name: string; type?: string | undefined; }'.ts(2322)
index.d.ts(11, 3): The expected type comes from property 'meta' which is declared here on type 'AddFileOptions'

Must anticipate I do understand the technical issue, but can't understand why I can't extend the meta.

Thanks!

@kvz kvz added the Types Issues relating to the Typescript definition files label May 29, 2019
@goto-bus-stop
Copy link
Contributor

Hmm, so I think when the typings were introduced the idea was to have strongly typed metadata. addFile() doesn't have the TMeta generic parameter that some of the other methods have, so it doesn't pass that through.

If I just add it like on the other methods, it still doesn't work though … will keep looking, at worst we'll have to just loosen the metadata type to be { name: string, type?: string, [anythingElse: string]: any }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Types Issues relating to the Typescript definition files
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants