akita-filters-plugin
akita-filters-plugin copied to clipboard
Support Number or Use ID for getFilterValue
getFilterValue is a convenient method available for getting a filter's value by its id.
This method expects a string, but a filter's id can be string | number (ID from akita).
This leads to this error when trying to use the following code.
TS2345: Argument of type 'ID' is not assignable to parameter of type 'string'.
Type 'number' is not assignable to type 'string'.
const myCustomFilter: AkitaFilterLocal<CustomState> = { ... };
function test(): void {
// Typescript reports an error here
this.dataSource.getFilterValue(this.myCustomFilter.id);
}
This error applies to AkitaFilterPlugin as well as the wrapper functions on AkitaMatDataSource.
These functions should accept ID so they can reference the filter's id directly without needing a type assertion.
Hi @itotallyrock ,
Thank you, for this issue. I had actually considered using it as a string. (because it seemed to me more sensible that the id of the filters is a string).
I think that at first, like Workaround, it should be possible to use the caste as a string.
Otherwise to fix this, I won't have the bandwidth to do it. But you can propose a PR, with the correction.
Thanks,