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

Type of fileRenameFunction is wrong? #20

Open
Gabiruti opened this issue Jan 3, 2024 · 0 comments
Open

Type of fileRenameFunction is wrong? #20

Gabiruti opened this issue Jan 3, 2024 · 0 comments

Comments

@Gabiruti
Copy link

Gabiruti commented Jan 3, 2024

I was trying to use fileRenameFunction with a promise on angular and i was getting this error:

Type '(file: { basename: string; extension: string; name: string; }) => Promise' is not assignable to type '((options: { basename: string; extension: string; name: string; }) => string) | Promise'.
Type '(file: { basename: string; extension: string; name: string; }) => Promise' is not assignable to type '(options: { basename: string; extension: string; name: string; }) => string'.
Type 'Promise' is not assignable to type 'string'.ts(2322)
ui-upload-order.component.ts(52, 33): Did you mean to call this expression?

so i changed the type of the function to:

// @ts-ignore
import { FilePondOptions } from "filepond";

declare module "filepond" {
    export interface FilePondOptions {
        /** Enable or disable file renaming */
        allowFileRename?: boolean;

        /** A function that receives an objecting containing file information like basename, extension and name. It should return either a string value or a Promise that resolves with a string value. */
        fileRenameFunction?:
        | undefined
        | null
        | ((options: {
            basename: string;
            extension: string;
            name: string;
        }) => string | Promise<string>);
    }
}

instead of:

// @ts-ignore
import { FilePondOptions } from "filepond";

declare module "filepond" {
    export interface FilePondOptions {
        /** Enable or disable file renaming */
        allowFileRename?: boolean;

        /** A function that receives an objecting containing file information like basename, extension and name. It should return either a string value or a Promise that resolves with a string value. */
        fileRenameFunction?:
        | undefined
        | null
        | ((options: {
            basename: string;
            extension: string;
            name: string;
        }) => string)
        | Promise<string>;
    }
}

and worked!

is it mean to be that way?

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