Solvedfine uploader Untyped exports from modules
βοΈAccepted Answer
Yes that page should work for TS instructions.
Little explanation to why things are the way they are right now:
I can easily add named exports to the def file, so something like this at the end
export { qq, FineUploader };
would do the job and then can be imported as such
import { qq, FineUploader } from 'fine-uploader';
and then you may do
let uploader = new qq.FineUploader(uiOptions);
But even then the type of variable uploader
here will be any
since the constructor doesn't return anything and cannot return anything as long as we're using a new
keyword.
This is a TypeScript rule that only a void function can be called with the new
keyword.
All of these things came into my attention while I was writing the definitions and since the original syntax is with the use of new
keyword, I had to keep the def that way and return void from constructors.
So in order to get proper tooling and all the TS goodies, you'll have to do
let uploader: FineUploader.qq = new qq.FineUploader(uiOptions);
Another problem with named exports that I have right now is with Rollup. (I can explain that later)
Which is what most of the Angular 2/ Typescript based projects use to generate production builds
I'll have to make sure that named exports work properly with Rollup before I can add it.
Type of issue
Uploader type
Fine Uploader version
5.14.1
Typescript version
2.1.6
Browsers where the bug is reproducible
n/a
Operating systems where the bug is reproducible
Windows 10 Pro
Exact steps required to reproduce the issue
fine-uploader
to Typescript file in projectDetailed explanation of the problem
Should the typescript definitions type the export of the modules?
When I have this in my file
import qq from 'fine-uploader/lib/core';
qq
is typeany
and I end up typing it manuallylet uploader: FineUploader.qq = new qq.FineUploader({});
Is there currently something about the library that preventing this feature from being added?
Also in the documentation the recommended approach for es2015 modules and traditional endpoints is to use the following code
which displays the following error at the first import statement
[ts] File 'c:/app/node_modules/fine-uploader/typescript/fine-uploader.d.ts' is not a module.