23 / resumable.js

A JavaScript library for providing multiple simultaneous, stable, fault-tolerant and resumable/restartable uploads via the HTML5 File API.
MIT License
4.65k stars 611 forks source link

generateUniqueIdentifier type in Typescript can't handle setting the built-in method #571

Open onilton opened 3 years ago

onilton commented 3 years ago
...
    generateUniqueIdentifier: ((file: File, event: Event) => {
        var relativePath = file.webkitRelativePath||file.fileName||file.name; // Some confusion in different versions of Firefox
        var size = file.size;
        return(size + '-' + relativePath.replace(/[^0-9a-zA-Z_-]/img, ''));
      }) as () => string,
...

Returns:

Type '(file: File, event: Event) => string' is not assignable to type '() => string'.ts(2322)

This happens because:

  generateUniqueIdentifier?: () => string;

Also, File type won't handle the attributes webkitRelativePath file.relativePath or file.fileName

onilton commented 3 years ago

Possibly related https://github.com/23/resumable.js/issues/542