Build process halted: Error encountered: Debug assertion failed. Incorrect expression detected

In my TypeScript library, I have a class that compiles to JavaScript:

ClassName = ClassName_1 = class ClassName{
...
}

ClassName = ClassName_1 = decorate([
...])

However, when I compile it with an Angular frontend that relies on this library using the following command:

./node_modules/.bin/ng build --configuration=development --base-href /client/ --deploy-url /client/

An error is thrown:

ERROR in ./node_modules/library/ClassName.js
Module build failed: Error: Debug Failure. False expression.

I am using TypeScript version 2.9.2 for an Angular 6 project. Even after trying version 7.0.0-rc with `3.0.3, the error persists.

Manually modifying the .js file bypasses the error:

ClassName = class ClassName{
...
}
ClassName_1 = ClassName

ClassName = ClassName_1 = decorate([
...])
ClassName_1 = ClassName

The problematic code causing the error is as follows:

/**
 * 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>();
    }

    // Other methods go here...

}

Answer №1

The issue was successfully replicated using TypeScript version 2.9.2. Here is the stack trace for reference:

Error: Debug Failure. False expression.
    at Object.getJSDocTags (.../typescript/lib/tsc.js:10302:22)
    at getJSDocTypeParameterDeclarations (.../typescript/lib/tsc.js:9069:30)
    at Object.getEffectiveTypeParameterDeclarations (.../typescript/lib/tsc.js:9065:67)
    at checkClassLikeDeclaration (.../typescript/lib/tsc.js:40190:36)
    at checkClassExpression (.../typescript/lib/tsc.js:40166:13)
    at checkExpressionWorker (.../typescript/lib/tsc.js:37693:28)
    at checkExpression (.../typescript/lib/tsc.js:37629:42)
    at checkBinaryLikeExpression (.../typescript/lib/tsc.js:37246:29)
    at checkBinaryExpression (.../typescript/lib/tsc.js:37238:20)
    at checkExpressionWorker (.../typescript/lib/tsc.js:37717:28)

Upon testing, it was observed that the error does not occur on TypeScript versions 3.0.3 or 3.1.3. To resolve this, make sure you are indeed utilizing version 3.0.3 by verifying with a simple code change like adding an unknown. If needed, one approach could be preventing TypeScript from loading the troublesome JavaScript file. While I am not acquainted with the Angular build system, enabling declaration file (.d.ts) generation for your library and ensuring its presence alongside the .js file during application build can prompt TypeScript to load the .d.ts file instead, leading to better type information.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Demonstrating the transformation of child elements into parent elements through angular 6 ngFor

I have a JSON array dataset where each object may contain nested arrays. In order to display the inner nested array elements as part of the parent array using Angular's NgFor, I need to format the input like this: [{ 'id': 1, 'tit ...

How can I customize the color of grayed-out days in Fullcalendar's validRange?

Hello there, I am currently using fullcalendar version 5.10.1 for my project and I am looking to change the color of already passed days to a more grayish tone as shown in the picture. Unfortunately, I am unable to utilize Ajax and can only use CSS styles. ...

The VS Code Prettier extension switches out single quotation marks for double ones and eliminates backslash marks

I've recently started working on an Angular project using VSCode, and I've been using the Prettier extension (version: 1.19.1). Everything was working fine, except for the fact that it doesn't allow me to write the regular expressions I need ...

Mastering Date Formatting with Pipe in Angular

Looking to format a date in Angular using pipes. Specifically, displaying the date as '24 September 2019'. Can anyone provide guidance on how to achieve this? Using Angular version 7 Appreciate any assistance. Thanks ...

Are SCSS style sheets being properly included in ng-packagr packaging?

I've been working on developing an Angular component library, packaging the modules for easy NPM installation. However, I took the old-school approach instead of using the CLI like Angular 6 recommends. Despite that, my components function properly wh ...

Conceal the message using star symbols

I need help figuring out how to hide a certain type of string input from the user, and then use Angular data binding to display it in another component with part of the data masked with asterisks. I'm not very skilled in JavaScript, so I'm wonder ...

The specified argument type 'AsyncThunkAction<any, number | undefined, {}>' cannot be assigned to the parameter type 'AnyAction'

I'm currently working on a web application using the Next.js framework. Our tech stack includes Next.js, Redux, and Redux-Thunk. I encountered an error while coding, hence why I'm posting this question. The error message reads: 'Argument ...

Looping through arrays within objects using NgFor in Angular 2/JavaScript

I have a custom object with data that I am iterating through using ngFor. Within this object, there is an array component that I also want to iterate through in a <li></li>. Currently, the output appears as one complete string within each < ...

Creating TypeScript unit tests for nested functions: A step-by-step guide

I'm currently working with Angular 16 in combination with the ngRx framework. My development involves TypeScript coding and writing unit tests (.spec.ts) using Jasmine, especially for code similar to the example below. How do I invoke this method with ...

Guide for setting ngTemplateOutput using the result of a function call

Below is the code snippet I am working with: <StackLayout formArrayName="products" *ngFor="let product of form.requestProduct.get('products')['controls']; let j=index"> <ng-container *ngTemplateOutlet="getTemplate(produc ...

Struggling to get NodeJS to render an HTML file containing a form and integrate it with Angular

In my project, I am using ExpressJS along with the EJS template view engine. The issue I am facing is related to displaying an HTML file on an Angular component. It seems that the form tag and its child input tags are not functioning properly on the Angula ...

Can a dynamic HTML page be created using Angular's ngClass directive and Bootstrap classes to ensure responsiveness?

Is there a way to dynamically resize buttons in my Angular application using the Bootstrap class btn-sm? I'm currently using this code snippet: <button [ngClass]="{ 'btn-sm' : window.screen.width < '575.5px' }"> ...

How to easily access object properties through ngModel select dropdown in Angular 2?

I am facing an issue when trying to access the properties of an object selected from a dropdown list in Angular 2 (RC1). Consider the following code snippet: <select required [(ngModel)]="model.plan"> <option selected="selected" disabled>Pla ...

Enforce a mandatory selection in a group of checkboxes depending on the input value in a

I have a new challenge with a form that includes a group of checkboxes and a textbox. I need to make the checkboxes mandatory based on the value entered in the textbox. I am looking for a way to declare the checkbox group similar to how I did it in the p ...

Tips for individually assigning Fastify decorators within various plugins?

I'm encountering issues with typing decorators in two separate plugins (scopes): import Fastify, { FastifyInstance } from 'fastify' const fastify = Fastify() // scope A fastify.register((instance) => { instance.decorate('utilA&apo ...

How to manually implement a scrollspy feature in Angular

I am facing an issue with implementing scrollspy inside a MatDialog. The event activate.bs.scrollspy doesn't appear to be triggering as expected. It seems like it might be firing at a window level and not highlighting the anchors on my navbar as I scr ...

Is there a way to load a JSON file into an Angular component using axios?

After generating an Angular 5 app using ng-cli, I created the following component: import {Component} from '@angular/core'; import axios from 'axios'; @Component({ selector: 'app-root', templateUrl: './app.component ...

gather and handle data from the shared interface between different parts

I have two different paths. One is for products and the other is for products-cart. I want to use a shared ts file for both to store the product and cart information in an array. However, I am encountering an issue. I am unable to make any changes or trans ...

NestJS: Having unique nullable email addresses breaches either the not-null constraint or the unique constraint

I need to include an email field in my User class that can be both nullable and unique. Here is the code I currently have: user.entity.ts: export class User { @Column({ name: 'email', nullable: true }) @Index('users_email_idx', ...

"Combining two regular expression patterns within a single input field in HTML5

When validating an input, I am looking for a combination of alphabets, numbers, and a specific length range. I want to display separate error messages for each pattern. One error message should indicate that the input should contain only alphabets and numb ...