fine-uploader
fine-uploader copied to clipboard
Incorrect TypeScript types for S3 customHeaders
Type of issue
- [x] Bug report
- [ ] Feature request
Uploader type
- [ ] Traditional
- [x] S3
- [x] Azure
Current:
/**
* type for S3's customHeaders function
*/
export interface S3CustomHeaderFunction {
(id: number): void;
}
[snip]
/**
* Additional headers sent along with each signature request.
*
* If you declare a function as the value, the associated file's ID will be passed to your function when it is invoked
*
* @default `{}`
*/
customHeaders?: any | S3CustomHeaderFunction;
The type should really be something like this:
customHeaders?:
| { [headerName: string]: string }
| ((fileId: number) => { [headerName: string]: string });
Is this working for you?
customHeaders?:
| { [headerName: string]: string }
| (fileId: number) => { [headerName: string]: string };
Isn't there an extra | at the beginning or I'm not reading it right
And I'm seeing some issues here
Isn't there an extra | at the beginning or I'm not reading it right
TypeScript has supported leading | for a while, see https://github.com/Microsoft/TypeScript/issues/12071. It was purely a stylistic choice from me to try and visually separate the two items of the union.
I'm going to wait for #1989 before raising a PR for this.
And I'm seeing some issues here
Thanks I was missing some parenthesis around the function, I've updated the snippet.