I'm currently trying to add this component to my typescript project, and I noticed that a lot of the example code throws a lot of typescript errors when you try to put the code inside a .tsx file.
For example, this sample: https://github.com/svar-widgets/react-filemanager/blob/main/demos/cases/BackendData.jsx
If you take this function (which I also saw in the docs in a couple places)
function previewURL(file, width, height) {
const ext = file.ext;
if (ext === "png" || ext === "jpg" || ext === "jpeg")
return (
server +
`/preview?width=${width}&height=${height}&id=${encodeURIComponent(file.id)}`
);
return false;
}
and then turn it into its typescript equivalent
function previewURL(file: IParsedEntity | { type: "search" | "multiple" | "none" }, width: number, height: number) {
const ext = file.ext;
if (ext === "png" || ext === "jpg" || ext === "jpeg")
return (
server +
`/preview?width=${width}&height=${height}&id=${encodeURIComponent(file.id)}`
);
return false;
}
you will get a "Property 'ext' does not exist on type 'IParsedEntity | { type: "search" | "multiple" | "none"; }'." error.
Additionally, if you look at the dedicated page for the previews attribute, it just states that this type attribute is a "preview state that can be "search" | "multiple" | "none"". So, I'm not even sure how to adjust my previewURL function to handle this attribute.
This is not the only example, this one where you're loading in data also throws a some typescript errors: https://docs.svar.dev/react/filemanager/guides/working_with_server/#loading-and-saving-data-with-restdataprovider
I would love it if there were some complete production examples of how to use this component, ideally with typescript.
I'm currently trying to add this component to my typescript project, and I noticed that a lot of the example code throws a lot of typescript errors when you try to put the code inside a .tsx file.
For example, this sample: https://github.com/svar-widgets/react-filemanager/blob/main/demos/cases/BackendData.jsx
If you take this function (which I also saw in the docs in a couple places)
and then turn it into its typescript equivalent
you will get a "Property 'ext' does not exist on type 'IParsedEntity | { type: "search" | "multiple" | "none"; }'." error.
Additionally, if you look at the dedicated page for the
previewsattribute, it just states that thistypeattribute is a "preview state that can be "search" | "multiple" | "none"". So, I'm not even sure how to adjust my previewURL function to handle this attribute.This is not the only example, this one where you're loading in data also throws a some typescript errors: https://docs.svar.dev/react/filemanager/guides/working_with_server/#loading-and-saving-data-with-restdataprovider
I would love it if there were some complete production examples of how to use this component, ideally with typescript.