У меня есть библиотека в машинописном тексте, которая компилирует класс в javascript:
ClassName = ClassName_1 = class ClassName{
...
}
ClassName = ClassName_1 = decorate([
...])
Это выдает ошибку, когда я компилирую с угловым интерфейсом, который зависит от этой библиотеки:
./node_modules/.bin/ng build --configuration=development --base-href /client/ --deploy-url /client/
Дается следующая ошибка:
ERROR in ./node_modules/library/ClassName.js
Module build failed: Error: Debug Failure. False expression.
Я компилирую все с помощью машинописи 2.9.2
, поскольку это проект Angular 6.Я попытался 7.0.0-rc
с `3.0.3, но у меня все еще есть эта ошибка, но у меня может быть ложный отрицательный результат здесь.
Если я вручную изменяю файл .js, он работает:
ClassName = class ClassName{
...
}
ClassName_1 = ClassName
ClassName = ClassName_1 = decorate([
...])
ClassName_1 = ClassName
Код с этой ошибкой:
/**
* Endpoint gives the baseDomain of MultiChat and gives the appropriate protocol.
* This is useful so you can pass through the same object to resources and streams types.
*
* A custom object is introduced to allow to pass the same object to use for WebSockets and https calls.
* Paths are also added to easily construct full routes.
*
* The design is to return full new objects so that you do not mix references.
*/
@injectable()
export class Endpoint {
public secure: boolean;
public baseDomain: string;
public paths: string[];
public port: number;
public queries: Map<string, string>;
/**
* init initializes the Endpoint with the correct baseDomain.
* @param secure is true if the _endpoint is reachable by HTTPS and WSS
* @param baseDomain the basedomain of the _endpoint, eg. independer.nl.
* @param paths additional paths to the _endpoint without slashes, eg. ["api"]
* @param port the port the _endpoint is hosted on
*/
constructor(secure: boolean, baseDomain: string, paths: string[] = [], port?: number) {
this.baseDomain = baseDomain;
this.paths = paths;
this.port = port;
this.secure = secure;
this.queries = new Map<string, string>();
}
/**
* addPath returns a new Endpoint object with the paths added and returns a clone of the Endpoint.
* @param paths
*/
public addPath(paths: string[]): Endpoint {
const result = this.cloneEndpoint();
result.paths = this.paths.concat(paths);
return result;
}
/**
* addQuery adds a new query parameter and returns a clone of the Endpoint.
* @param key The key of the parameter.
* @param value The value of the parameter.
*/
public addQuery(key: string, value: string): Endpoint {
const result = this.cloneEndpoint();
result.queries.set(key, value);
return result;
}
/**
* getHTTP returns the HTTP baseDomain string.
* If the baseDomain is secure it returns HTTPS.
*/
public getHTTP(): string {
const protocol = (this.secure ? "https" : "http");
return this.getEndpoint(protocol);
}
/**
* getWS returns the WebSocket baseDomain string.
* * If the baseDomain is secure it returns WSS.
*/
public getWS(): string {
const protocol = (this.secure ? "wss" : "ws");
return this.getEndpoint(protocol);
}
private cloneEndpoint(): Endpoint {
return new Endpoint(this.secure, this.baseDomain, this.paths, this.port);
}
private getEndpoint(protocol: string) {
const port = (this.port ? ":" + this.port : "");
let endpoint = protocol + "://" + this.baseDomain + port;
endpoint += this.getPath();
if (this.queries.size) {
endpoint += "?";
let first = true;
for (const key of this.queries.keys()) {
if (!first) {
endpoint += "&";
}
endpoint += key + "=" + encodeURIComponent(this.queries.get(key));
first = false;
}
}
return endpoint;
}
private getPath(): string {
let fullPath = "";
for (const path of this.paths) {
fullPath += "/" + path;
}
return fullPath;
}
}