Skip to content

Commit db77e89

Browse files
marvinscharlevalorkin
authored andcommitted
fix(zone.js): error in Safari, Added Typings (#221)
* Changed tsconfig.json to match tsconfig schema * Change package.json to include all necessary packages for this package * Added type for EventEmitter * Fix for zone.js error "More tasks executed then were scheduled" in Safari, explicit call of NgZone not required in zone.js ^0.6.12 * Added type information for methods in FileUploader * Added type information for methods in FileItem * Added type information for methods in FileUploader * Removed codelyzer / eslint according to PR #221
1 parent ec1e5ae commit db77e89

5 files changed

Lines changed: 73 additions & 74 deletions

File tree

components/file-upload/file-drop.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FileUploader } from './file-uploader.class';
66
export class FileDropDirective {
77
@Input() public uploader:FileUploader;
88
@Output() public fileOver:EventEmitter<any> = new EventEmitter();
9-
@Output() public onFileDrop:EventEmitter<File[]> = new EventEmitter();
9+
@Output() public onFileDrop:EventEmitter<File[]> = new EventEmitter<File[]>();
1010

1111
private element:ElementRef;
1212
public constructor(element:ElementRef) {

components/file-upload/file-item.class.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {NgZone} from '@angular/core';
2-
31
import {FileLikeObject} from './file-like-object.class';
4-
import {FileUploader} from './file-uploader.class';
2+
import {FileUploader, ParsedResponseHeaders, FileUploaderOptions} from './file-uploader.class';
53

64
export class FileItem {
75
public file:FileLikeObject;
@@ -20,28 +18,28 @@ export class FileItem {
2018
public isError:boolean = false;
2119
public progress:number = 0;
2220
public index:number = void 0;
23-
private _zone:NgZone;
21+
public _xhr:XMLHttpRequest;
22+
public _form:any;
2423

2524
private uploader:FileUploader;
26-
private some:any;
27-
private options:any;
25+
private some:File;
26+
private options:FileUploaderOptions;
2827

29-
public constructor(uploader:FileUploader, some:any, options:any) {
28+
public constructor(uploader:FileUploader, some:File, options:FileUploaderOptions) {
3029
this.uploader = uploader;
3130
this.some = some;
3231
this.options = options;
3332
this.file = new FileLikeObject(some);
3433
this._file = some;
3534
this.url = uploader.options.url;
36-
this._zone = new NgZone({ enableLongStackTrace: false });
3735
}
3836

3937
public upload():void {
4038
try {
4139
this.uploader.uploadItem(this);
4240
} catch (e) {
43-
this.uploader._onCompleteItem(this, '', 0, []);
44-
this.uploader._onErrorItem(this, '', 0, []);
41+
this.uploader._onCompleteItem(this, '', 0, {});
42+
this.uploader._onErrorItem(this, '', 0, {});
4543
}
4644
}
4745

@@ -65,19 +63,19 @@ export class FileItem {
6563
return {progress};
6664
}
6765

68-
public onSuccess(response:any, status:any, headers:any):any {
66+
public onSuccess(response:string, status:number, headers:ParsedResponseHeaders):any {
6967
return {response,status,headers};
7068
}
7169

72-
public onError(response:any, status:any, headers:any):any {
70+
public onError(response:string, status:number, headers:ParsedResponseHeaders):any {
7371
return {response,status,headers};
7472
}
7573

76-
public onCancel(response:any, status:any, headers:any):any {
74+
public onCancel(response:string, status:number, headers:ParsedResponseHeaders):any {
7775
return {response,status,headers};
7876
}
7977

80-
public onComplete(response:any, status:any, headers:any):any {
78+
public onComplete(response:string, status:number, headers:ParsedResponseHeaders):any {
8179
return {response,status,headers};
8280
}
8381

@@ -97,13 +95,11 @@ export class FileItem {
9795
}
9896

9997
public _onProgress(progress:number):void {
100-
this._zone.run(() => {
101-
this.progress = progress;
102-
});
98+
this.progress = progress;
10399
this.onProgress(progress);
104100
}
105101

106-
public _onSuccess(response:any, status:any, headers:any):void {
102+
public _onSuccess(response:string, status:number, headers:ParsedResponseHeaders):void {
107103
this.isReady = false;
108104
this.isUploading = false;
109105
this.isUploaded = true;
@@ -115,7 +111,7 @@ export class FileItem {
115111
this.onSuccess(response, status, headers);
116112
}
117113

118-
public _onError(response:any, status:any, headers:any):void {
114+
public _onError(response:string, status:number, headers:ParsedResponseHeaders):void {
119115
this.isReady = false;
120116
this.isUploading = false;
121117
this.isUploaded = true;
@@ -127,7 +123,7 @@ export class FileItem {
127123
this.onError(response, status, headers);
128124
}
129125

130-
public _onCancel(response:any, status:any, headers:any):void {
126+
public _onCancel(response:string, status:number, headers:ParsedResponseHeaders):void {
131127
this.isReady = false;
132128
this.isUploading = false;
133129
this.isUploaded = false;
@@ -139,7 +135,7 @@ export class FileItem {
139135
this.onCancel(response, status, headers);
140136
}
141137

142-
public _onComplete(response:any, status:any, headers:any):void {
138+
public _onComplete(response:string, status:number, headers:ParsedResponseHeaders):void {
143139
this.onComplete(response, status, headers);
144140

145141
if (this.uploader.options.removeAfterUpload) {

0 commit comments

Comments
 (0)