-
Notifications
You must be signed in to change notification settings - Fork 32
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
FilePondComponent doesn't have methods defined in type definitions #40
Comments
I'm experiencing the same issue using |
Happy to accept a PR 👍 |
@rikschennink can you point out the type definition file for |
@mtpultz The methods are copied dynamically from the FilePond instance to the FilePondComponent instance (https://github.com/pqina/ngx-filepond/blob/master/src/app/modules/filepond/filepond.component.ts#L140). So maybe an interface needs to be added to the component (I'm not a TypeScript pro)? |
Hi @rikschennink thanks for the reply. I realize they are copied over similar to how the event emitters are mapped. We can use To get around this I added a temporary fix:
But, updating the type definition of Example: import { ElementRef, SimpleChanges, NgZone } from '@angular/core';
import * as ɵngcc0 from '@angular/core';
import { ActualFileObject, FilePond, FilePondEventPrefixed, FilePondFile, FilePondInitialFile, FilePondOptions, RemoveFileOptions } from 'filepond';
// Set of methods from the FilePond type definition
// @see https://github.com/pqina/filepond/blob/master/types/index.d.ts#L807
export declare class FilePondActions {
/**
* Adds a file.
* @param options.index The index that the file should be added at.
*/
addFile(source: ActualFileObject | Blob | string, options?: { index?: number } & Partial<FilePondInitialFile["options"]>): Promise<FilePondFile>;
/**
* Adds multiple files.
* @param options.index The index that the files should be added at.
*/
addFiles(source: ActualFileObject[] | Blob[] | string[], options?: { index: number }): Promise<FilePondFile[]>;
/**
* Moves a file. Select file with query and supply target index.
* @param query The file reference, id, or index.
* @param index The index to move the file to.
*/
moveFile(query: FilePondFile | string | number, index: number): void;
/**
* Removes a file.
* @param query The file reference, id, or index. If no query is provided, removes the first file in the list.
* @param options Options for removal
*/
removeFile(query?: FilePondFile | string | number, options?: RemoveFileOptions): void;
/**
* Removes the first file in the list.
* @param options Options for removal
*/
removeFile(options: RemoveFileOptions): void;
/**
* Removes files matching the query.
* @param query Array containing file references, ids, and/or indexes. If no array is provided, all files are removed
* @param options Options for removal
*/
removeFiles(query?: Array<FilePondFile | string | number>, options?: RemoveFileOptions): void;
/**
* Removes all files.
* @param options Options for removal
*/
removeFiles(options: RemoveFileOptions): void;
/**
* Processes a file. If no parameter is provided, processes the first file in the list.
* @param query The file reference, id, or index
*/
processFile(query?: FilePondFile | string | number): Promise<FilePondFile>;
/**
* Processes multiple files. If no parameter is provided, processes all files.
* @param query The file reference(s), id(s), or index(es)
*/
processFiles(query?: FilePondFile[] | string[] | number[]): Promise<FilePondFile[]>;
/**
* Starts preparing the file matching the given query, returns a Promise, the Promise is resolved with the file item and the output file { file, output }
* @param query The file reference, id, or index
*/
prepareFile(query?: FilePondFile | string | number): Promise<{ file: FilePondFile, output: any }>;
/**
* Processes multiple files. If no parameter is provided, processes all files.
* @param query Array containing file reference(s), id(s), or index(es)
*/
prepareFiles(query?: FilePondFile[] | string[] | number[]): Promise<Array<{ file: FilePondFile, output: any }>>;
/**
* Returns a file. If no parameter is provided, returns the first file in the list.
* @param query The file id, or index
*/
getFile(query?: string | number): FilePondFile;
/** Returns all files. */
getFiles(): FilePondFile[];
/**
* Manually trigger the browse files panel.
*
* Only works if the call originates from the user.
*/
browse(): void;
/**
* Sort the items in the files list.
* @param compare The comparison function
*/
sort(compare: (a: FilePondFile, b: FilePondFile) => number): void;
/**
* Adds an event listener to the given event.
* @param event Name of the event, prefixed with `Filepond:`
* @param fn Event handler
*/
addEventListener(event: FilePondEventPrefixed, fn: (e: any) => void): void;
}
export declare class FilePondComponent extends FilePondActions {
options: Object;
files: Array<any>;
private root;
private zone;
private pond;
private handleEvent;
constructor(root: ElementRef, zone: NgZone);
ngAfterViewInit(): void;
ngOnChanges(changes: SimpleChanges): void;
ngOnDestroy(): void;
static ɵfac: ɵngcc0.ɵɵFactoryDef<FilePondComponent, never>;
static ɵcmp: ɵngcc0.ɵɵComponentDefWithMeta<FilePondComponent, "file-pond", never, { "options": "options"; "files": "files"; }, { "oninit": "oninit"; "onwarning": "onwarning"; "onerror": "onerror"; "onactivatefile": "onactivatefile"; "onaddfilestart": "onaddfilestart"; "onaddfileprogress": "onaddfileprogress"; "onaddfile": "onaddfile"; "onprocessfilestart": "onprocessfilestart"; "onprocessfileprogress": "onprocessfileprogress"; "onprocessfileabort": "onprocessfileabort"; "onprocessfilerevert": "onprocessfilerevert"; "onprocessfile": "onprocessfile"; "onprocessfiles": "onprocessfiles"; "onremovefile": "onremovefile"; "onpreparefile": "onpreparefile"; "onupdatefiles": "onupdatefiles"; }, never, never>;
} |
@mtpultz I think the definitions are derived from the component, the FilePond types are in the types folder of the core repo. (maybe I misunderstand the question). |
@rikschennink yah I wasn't sure where the definitions were being created, but figured out it's |
@mtpultz aha! So it also generates a typescript file, gotcha! |
@rikschennink can't seem to run |
Feature Request
https://pqina.nl/filepond/docs/patterns/api/filepond-instance/#methods defines a set of methods that can be called on a filepond instance. These methods are not found in the type definition of the FilepondComponent thus throwing build time errors when trying to access them. Though with some testing these methods work when called. Can these methods be added to the FilePondComponent?
The text was updated successfully, but these errors were encountered: