Skip to content

Commit 69cd64d

Browse files
feat(bump): added strict mode, doesn't build in dist, should be resolved
1 parent 16078f5 commit 69cd64d

15 files changed

Lines changed: 122 additions & 84 deletions

angular.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
"architect": {
1111
"build": {
1212
"builder": "@angular-devkit/build-ng-packagr:build",
13+
"outputs": [
14+
"./dist/ng2-file-upload"
15+
],
1316
"options": {
14-
"tsConfig": "src/tsconfig.json",
17+
"tsConfig": "src/tsconfig.lib.json",
1518
"project": "src/ng-package.json"
1619
},
1720
"configurations": {
1821
"production": {
19-
"tsConfig": "src/tsconfig.prod.json"
22+
"tsConfig": "src/tsconfig.lib.prod.json"
2023
}
2124
}
2225
}

demo/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link rel="author" href="https://github.com/valor-software/ng2-file-upload/graphs/contributors">
1313

1414
<!--link to bootstrap.css-->
15-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
15+
<link rel="stylesheet" crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
1616
<link rel="stylesheet" href="assets/css/style.css">
1717
<link rel="stylesheet" href="assets/css/prettify-angulario.css">
1818
<style media="screen">

demo/src/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@
2121
],
2222
"exclude": [
2323
"**/*.spec.ts"
24-
]
24+
],
25+
"paths": {
26+
"@ng2-file-upload": [
27+
"../../dist/ng2-file-upload/index.ts"
28+
]
29+
}
2530
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"tslint": "^6.1.0",
105105
"tslint-config-valorsoft": "^2.2.1",
106106
"typedoc": "0.20.36",
107-
"typescript": "~4.1.5",
107+
"typescript": "4.1.5",
108108
"wallaby-webpack": "^3.9.16",
109109
"webdriver-manager": "12.1.8",
110110
"zone.js": "~0.11.3"

scripts/polyfills.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
// This file includes polyfills needed by Angular 2 and is loaded before
22
// the app. You can add your own extra polyfills to this file.
33
import 'ts-helpers';
4-
import 'core-js/es/symbol';
5-
import 'core-js/es/object';
6-
import 'core-js/es/function';
7-
import 'core-js/es/parse-int';
8-
import 'core-js/es/parse-float';
9-
import 'core-js/es/number';
10-
import 'core-js/es/math';
11-
import 'core-js/es/string';
12-
import 'core-js/es/date';
13-
import 'core-js/es/array';
14-
import 'core-js/es/regexp';
15-
import 'core-js/es/map';
16-
import 'core-js/es/set';
17-
import 'core-js/es/reflect';
18-
19-
import 'core-js/es/reflect';
204
import 'zone.js/dist/zone';
215
import 'classlist-polyfill';

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FileUploader, FileUploaderOptions } from './file-uploader.class';
44

55
@Directive({ selector: '[ng2FileDrop]' })
66
export class FileDropDirective {
7-
@Input() public uploader: FileUploader;
7+
@Input() public uploader?: FileUploader;
88
@Output() public fileOver: EventEmitter<any> = new EventEmitter();
99
@Output() public onFileDrop: EventEmitter<File[]> = new EventEmitter<File[]>();
1010

@@ -14,8 +14,8 @@ export class FileDropDirective {
1414
this.element = element;
1515
}
1616

17-
public getOptions(): FileUploaderOptions {
18-
return this.uploader.options;
17+
public getOptions(): FileUploaderOptions | void {
18+
return this.uploader?.options;
1919
}
2020

2121
public getFilters(): any {
@@ -32,7 +32,9 @@ export class FileDropDirective {
3232
let options = this.getOptions();
3333
let filters = this.getFilters();
3434
this._preventAndStop(event);
35-
this.uploader.addToQueue(transfer.files, options, filters);
35+
if (options) {
36+
this.uploader?.addToQueue(transfer.files, options, filters);
37+
}
3638
this.fileOver.emit(false);
3739
this.onFileDrop.emit(transfer.files);
3840
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { FileUploader, ParsedResponseHeaders, FileUploaderOptions } from './file
44
export class FileItem {
55
public file: FileLikeObject;
66
public _file: File;
7-
public alias: string;
8-
public url: string = '/';
9-
public method: string;
7+
public alias?: string;
8+
public url? = '/';
9+
public method?: string;
1010
public headers: any = [];
1111
public withCredentials: boolean = true;
1212
public formData: any = [];
@@ -17,8 +17,8 @@ export class FileItem {
1717
public isCancel: boolean = false;
1818
public isError: boolean = false;
1919
public progress: number = 0;
20-
public index: number = void 0;
21-
public _xhr: XMLHttpRequest;
20+
public index?: number;
21+
public _xhr?: XMLHttpRequest;
2222
public _form: any;
2323

2424
protected uploader: FileUploader;
@@ -111,7 +111,7 @@ export class FileItem {
111111
this.isCancel = false;
112112
this.isError = false;
113113
this.progress = 100;
114-
this.index = void 0;
114+
this.index = undefined;
115115
this.onSuccess(response, status, headers);
116116
}
117117

@@ -123,7 +123,7 @@ export class FileItem {
123123
this.isCancel = false;
124124
this.isError = true;
125125
this.progress = 0;
126-
this.index = void 0;
126+
this.index = undefined;
127127
this.onError(response, status, headers);
128128
}
129129

@@ -135,7 +135,7 @@ export class FileItem {
135135
this.isCancel = true;
136136
this.isError = false;
137137
this.progress = 0;
138-
this.index = void 0;
138+
this.index = undefined;
139139
this.onCancel(response, status, headers);
140140
}
141141

src/file-upload/file-like-object.class.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ function isElement(node: any): boolean {
55
export class FileLikeObject {
66
public lastModifiedDate: any;
77
public size: any;
8-
public type: string;
9-
public name: string;
8+
public type?: string;
9+
public name?: string;
1010
public rawFile: string;
1111

1212
public constructor(fileOrInput: any) {

src/file-upload/file-select.directive.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Directive, EventEmitter, ElementRef, Input, HostListener, Output } from '@angular/core';
22

3-
import { FileUploader } from './file-uploader.class';
3+
import {FileUploader, FileUploaderOptions} from './file-uploader.class';
44

55
@Directive({ selector: '[ng2FileSelect]' })
66
export class FileSelectDirective {
7-
@Input() public uploader: FileUploader;
7+
@Input() public uploader?: FileUploader;
88
@Output() public onFileSelected: EventEmitter<File[]> = new EventEmitter<File[]>();
99

1010
protected element: ElementRef;
@@ -13,8 +13,8 @@ export class FileSelectDirective {
1313
this.element = element;
1414
}
1515

16-
public getOptions(): any {
17-
return this.uploader.options;
16+
public getOptions(): FileUploaderOptions | void {
17+
return this.uploader?.options;
1818
}
1919

2020
public getFilters(): any {
@@ -30,10 +30,11 @@ export class FileSelectDirective {
3030
let files = this.element.nativeElement.files;
3131
let options = this.getOptions();
3232
let filters = this.getFilters();
33+
if (options) {
34+
this.uploader?.addToQueue(files, options, filters);
35+
}
3336

34-
this.uploader.addToQueue(files, options, filters);
3537
this.onFileSelected.emit(files);
36-
3738
if (this.isEmptyAfterSelection()) {
3839
this.element.nativeElement.value = '';
3940
}

src/file-upload/file-type.class.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@ export class FileType {
6262

6363
public static getMimeClass(file: FileLikeObject): string {
6464
let mimeClass = 'application';
65-
if (this.mime_psd.indexOf(file.type) !== -1) {
65+
if (file?.type && this.mime_psd.indexOf(file.type) !== -1) {
6666
mimeClass = 'image';
67-
} else if (file.type.match('image.*')) {
67+
} else if (file?.type?.match('image.*')) {
6868
mimeClass = 'image';
69-
} else if (file.type.match('video.*')) {
69+
} else if (file?.type?.match('video.*')) {
7070
mimeClass = 'video';
71-
} else if (file.type.match('audio.*')) {
71+
} else if (file?.type?.match('audio.*')) {
7272
mimeClass = 'audio';
73-
} else if (file.type === 'application/pdf') {
73+
} else if (file?.type === 'application/pdf') {
7474
mimeClass = 'pdf';
75-
} else if (this.mime_compress.indexOf(file.type) !== -1) {
75+
} else if (file?.type && this.mime_compress.indexOf(file.type) !== -1) {
7676
mimeClass = 'compress';
77-
} else if (this.mime_doc.indexOf(file.type) !== -1) {
77+
} else if (file?.type && this.mime_doc.indexOf(file.type) !== -1) {
7878
mimeClass = 'doc';
79-
} else if (this.mime_xsl.indexOf(file.type) !== -1) {
79+
} else if (file?.type && this.mime_xsl.indexOf(file.type) !== -1) {
8080
mimeClass = 'xls';
81-
} else if (this.mime_ppt.indexOf(file.type) !== -1) {
81+
} else if (file?.type && this.mime_ppt.indexOf(file.type) !== -1) {
8282
mimeClass = 'ppt';
8383
}
84-
if (mimeClass === 'application') {
84+
if (mimeClass === 'application' && file?.name) {
8585
mimeClass = this.fileTypeDetection(file.name);
8686
}
8787

0 commit comments

Comments
 (0)