Using Dropzone with Typescript
I have an application that uses dropzone 4.3 and writes to Typescript. Before converting it to typescript, we needed to set a global variable to Dropzone and everything was happy.
Dropzone.autoDiscover = false;
I pulled in these node packages:
"@types/dropzone": "^4.3.35",
"dropzone": "4.3.0",
Now the autodiscover line gives me this error:
Error TS2686 'Dropzone' refers to a UMD global, but the current file is a module. Consider adding an import instead.
To solve this problem, I added the following:
import * as Dropzone from 'dropzone';
Now I am left with this error:
Error TS2540 Cannot assign to 'autoDiscover' because it is a constant or a read-only property.
Where did I go wrong?
+3
source to share
1 answer
You can set autoDiscover to false like this
import * as Dropzone from "dropzone";
const dz = Dropzone
dz.autoDiscover = false;
I found it from this link https://github.com/zefoy/ngx-dropzone-wrapper/blob/fb39139147f3a6d72bcaff51c3c32e2a54e31c9d/src/lib/dropzone.directive.ts#L60
0
source to share