Estou tentando gerar o build de um projeto em Angular, porém toda vez que rodo o comando para isso ng build
é me apresentado vários erros, porém pesquisando não consegui resolver, alguém teria uma luz?
E:\Sistemas\sourcecode>ng build --source-map=false --prod --deploy-url=client/
Date: 2019-01-09T17:29:00.855Z
Hash: 00b6ba86f5c09a5273e8
Time: 121743ms
chunk {0} runtime.8004edb872d7c3b82213.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.9868d9b237c3a48c54da.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills.85f47f0bf59079cbc23a.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} styles.0befdcbdc7f0c4753cdc.css (styles) 75.2 kB [initial] [rendered]
ERROR in src/common/uploads/utils/upload-progress-event.ts(47,17): error TS2322: Type 'HttpEventType.UploadProgress | HttpEventType.DownloadProgress' is not assignable to type 'HttpEventType.Sent | HttpEventType.UploadProgress | HttpEventType.Response'.
Type 'HttpEventType.DownloadProgress' is not assignable to type 'HttpEventType.Sent | HttpEventType.UploadProgress | HttpEventType.Response'.
src/common/uploads/uploaded-file.ts(19,34): error TS2339: Property 'webkitRelativePath' does not exist on type 'File'.
src/common/uploads/uploaded-file.ts(27,25): error TS2345: Argument of type 'string | ArrayBuffer' is not assignable to parameter of type 'string | PromiseLike<string>'.
Type 'ArrayBuffer' is not assignable to type 'string | PromiseLike<string>'.
Type 'ArrayBuffer' is not assignable to type 'string'.
src/common/uploads/utils/create-upload-input.ts(31,15): error TS2339: Property 'webkitdirectory' does not exist on type 'HTMLInputElement'.
src/common/uploads/utils/read-uploaded-folders.ts(3,52): error TS2304: Cannot find name 'WebKitEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(10,58): error TS2304: Cannot find name 'WebKitFileEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(12,66): error TS2304: Cannot find name 'WebKitDirectoryEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(19,40): error TS2304: Cannot find name 'WebKitDirectoryEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(26,50): error TS2304: Cannot find name 'WebKitDirectoryEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(28,63): error TS2304: Cannot find name 'WebKitFileEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(35,27): error TS2304: Cannot find name 'WebKitDirectoryEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(35,58): error TS2304: Cannot find name 'WebKitEntry'.
src/common/uploads/utils/read-uploaded-folders.ts(42,36): error TS2304: Cannot find name 'WebKitFileEntry'.
Aqui o meu tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"common": [
"common/"
]
},
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
E aqui o meu read-uploaded-folders.ts
import { UploadedFile } from '../uploaded-file';
export async function readUploadedFolders(entries: WebKitEntry[]): Promise<UploadedFile[]> {
let files = [];
for (const key in entries) {
const entry = entries[key];
if ( ! entry.isDirectory) {
files.push(await transformFileEntry(entry as WebKitFileEntry));
} else {
files = files.concat(await readDirRecursive(entry as WebKitDirectoryEntry));
}
}
return files;
}
async function readDirRecursive(entry: WebKitDirectoryEntry, files = []) {
const entries = await readEntries(entry);
for (const key in entries) {
const childEntry = entries[key];
if (childEntry.isDirectory) {
await readDirRecursive(childEntry as WebKitDirectoryEntry, files);
} else {
files.push(await transformFileEntry(childEntry as WebKitFileEntry));
}
}
return files;
}
function readEntries(dir: WebKitDirectoryEntry): Promise<WebKitEntry[]> {
return new Promise(resolve => {
const reader = dir.createReader();
reader.readEntries(entries => resolve(entries as any));
});
}
function transformFileEntry(entry: WebKitFileEntry) {
return new Promise(resolve => {
entry.file((file: any) => {
resolve(new UploadedFile(file as File, entry.fullPath));
});
});
}
Arquivo upload-progress-event.ts
import { HttpEvent, HttpEventType } from '@angular/common/http';
import { getUploadProgress } from './get-upload-progress';
import { getUploadSpeed } from './get-upload-speed';
import { getUploadETA } from './get-upload-eta';
import { prettyUploadETA } from './pretty-upload-eta';
import { prettyBytes } from '../../core/utils/pretty-bytes';
import { FileEntry } from '../file-entry';
import { BackendResponse } from '../../core/types/backend-response';
export enum UploadEventTypes {
STARTED = 'uploadStarted',
PROGRESS = 'uploadProgress',
COMPLETED = 'uploadCompleted',
OTHER = 'unrecognizedEvent'
}
export interface UploadCompletedEvent {
type: HttpEventType.Response;
name: UploadEventTypes.COMPLETED;
fileEntry: FileEntry;
}
export interface UploadProgressEvent {
type: HttpEventType.UploadProgress;
name: UploadEventTypes.PROGRESS;
totalBytes: number;
completedBytes: number;
progress: number;
speed: string;
eta: string;
}
export interface UploadStartedEvent {
type: HttpEventType.Sent;
name: UploadEventTypes.STARTED;
time: number;
}
export type UploadEvent = UploadStartedEvent | UploadCompletedEvent | UploadProgressEvent;
export function transformAngularUploadEvent<T>(e: HttpEvent<{fileEntry: FileEntry}>, uploadStarted: number): UploadEvent {
switch (e.type) {
case HttpEventType.Sent:
return {type: e.type, name: UploadEventTypes.STARTED, time: uploadStarted};
case HttpEventType.UploadProgress:
return {
type: e.type,
name: UploadEventTypes.PROGRESS,
totalBytes: e.total,
completedBytes: e.loaded,
progress: getUploadProgress(e),
speed: prettyBytes(getUploadSpeed(e, uploadStarted)),
eta: prettyUploadETA(getUploadETA(e, uploadStarted)),
};
case HttpEventType.Response:
return {type: e.type, name: UploadEventTypes.COMPLETED, fileEntry: e.body.fileEntry};
default:
return null;
}
}
src/common/uploads/utils/upload-progress-event.ts
,src/common/uploads/uploaded-file.ts
,src/common/uploads/utils/create-upload-input.ts
esrc/common/uploads/utils/read-uploaded-folders.ts
. Você leu a mensagem de erro? Da segunda linha em branco para baixo há a descrição do arquivo, linha, coluna e detalhes do que está errado.--no-aot
ao compilar, nem lembro o que faz, mas pra mim resolveu