From 28c993544df73665a7dc14c4adaf49e033286579 Mon Sep 17 00:00:00 2001 From: Fahmi Akbar Wildana Date: Sat, 24 Mar 2018 16:29:07 +0700 Subject: [PATCH] Fix missing declare and upload.file doesn't exist - Fix ERR: A 'declare' modifier is required for a top level declaration in a .d.ts file. - Fix ERR: Property 'file' does not exist on type 'File' when using it like `this.image = URL.createObjectURL(upload.file)` - `VueUpload.File` type is conflicted with https://developer.mozilla.org/en-US/docs/Web/API/File so need to change to VUFile (ts don't have a way to resolve this) --- index.d.ts | 63 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4f3c22d..d8ff42c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,44 +1,43 @@ import Vue from 'vue' - + // Instance / File -global { - namespace VueUpload { - interface File { - readonly fileObject: boolean - id: string | number - size: number - name: string - type: string - active: boolean - error: string - success: boolean - putAction: string - postAction: string - headers: object - data: object - timeout: number - response: object | string - progress: string - speed: number - xhr: XMLHttpRequest - iframe: Element - } +declare global { + interface VUFile { + file: File + readonly fileObject: boolean + id: string | number + size: number + name: string + type: string + active: boolean + error: string + success: boolean + putAction: string + postAction: string + headers: object + data: object + timeout: number + response: object | string + progress: string + speed: number + xhr: XMLHttpRequest + iframe: Element } } -class _ extends Vue { +declare class _ extends Vue { // Instance / Methods - get(id: VueUpload.File | object | string): VueUpload.File | object | boolean - add(files: Array | VueUpload.File | File | object): object | Array | boolean - addInputFile(el: HTMLInputElement): Array - addDataTransfer(dataTransfer: DataTransfer): Promise> - update(id: VueUpload.File | object | string, data: object): object | boolean - remove(id: VueUpload.File | object | string): object | boolean - replace(id1: VueUpload.File | object | string, id2: VueUpload.File | object | string): boolean + get(id: VUFile | object | string): VUFile | object | boolean + add(files: Array | VUFile | File | object): object | Array | boolean + addInputFile(el: HTMLInputElement): Array + addDataTransfer(dataTransfer: DataTransfer): Promise> + update(id: VUFile | object | string, data: object): object | boolean + remove(id: VUFile | object | string): object | boolean + replace(id1: VUFile | object | string, id2: VUFile | object | string): boolean clear(): boolean // Instance / Data - readonly files: Array + readonly files: Array readonly features: { html5?: boolean; directory?: boolean; drag?: boolean } active: boolean readonly dropActive: true