Error: KotlinJS + Typescript cannot locate the Atomicfu TraceBase reference in the d.ts file

When the npm library KotlinJS is published with either the coroutine or ktor dependency, the resulting generated typescript d.ts file contains references to atomicfu.

export namespace kotlinx.atomicfu {
    function atomic$ref$<T>(initial: T, trace: kotlinx.atomicfu.TraceBase): kotlinx.atomicfu.AtomicRef<T>;
    function atomic$boolean$(initial: boolean, trace: kotlinx.atomicfu.TraceBase): kotlinx.atomicfu.AtomicBoolean;
    function atomic$int$(initial: number, trace: kotlinx.atomicfu.TraceBase): kotlinx.atomicfu.AtomicInt;
    function atomic$long$(initial: kotlin.Long, trace: kotlinx.atomicfu.TraceBase): kotlinx.atomicfu.AtomicLong;
}

However, the reference for TraceBase is missing from the file. When compiling a Typescript app that depends on the above kotlinJS library, it raises an error about the absence of TraceBase.

The only workaround currently is to add skipLibCheck = true in the tsconfig file, which is not an ideal solution for users of the library.

Is there a better way to address this issue?

Answer №1

There seems to be a known issue with the compiler causing a bug, which has been documented and can be found here for reference:

A temporary solution using Gradle involves removing any references to atomicfu from the generated d.ts file.

If you are using the NPM package publishing Gradle plugin available at this link, you can follow the steps outlined below:

Add the following two Gradle tasks to your project:

// code snippet provided here

// Ensure that the 'removeAtomicFu' task is executed after the 'assembleJsNpmPublication' task
project.afterEvaluate {
    tasks.findByName("assembleJsNpmPublication")?.finalizedBy("removeAtomicFu")
}

Upon running ./gradlew packJsNpmPublication, the build content will no longer contain any atomicfu references.

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

Tips for easily refreshing the contents of all EditTexts within a RecyclerView using two-way data binding

In my application, I have a RecyclerView that displays CardViews. Each CardView contains an EditText which calculates the user's input amount multiplied by a specific rate (the rates are fetched from an API endpoint and differ for each row). Data bind ...

The argument of type 'InputType[]' is incompatible with the parameter of type 'GenericType[]' in Typescript

In this scenario, I am developing a utility function with the objective of dynamically sorting an array of objects (the first parameter) in alphabetical order, based on a specified key passed as the second argument. The utility function is defined as foll ...

Concealing the value of 'Zero' in an input field with TypeScript and Angular 2

<input type="text" class="form-control" id="transactionAmount" maxlength="10" HideZero="true" [(ngModel)]="userBalance.transactionAmount" ...

Can I include `ChangeDetectorRef` in an Angular 4 service constructor?

In my service file, I have a system that alerts about Subjects. The value is set and then reset to null after 3 seconds using the setTimeout() method. However, upon adding changeDetection: ChangeDetectionStrategy.OnPush to the app.component.ts, it appears ...

Passing Down Instance Methods Using Static References in JavaScript/TypeScript

✋ Exploring the concept of access modifiers from TypeScript, how can we make it relevant for JavaScript developers as well? Let's consider a scenario where a parent class defines necessary members and a shared method: // ParentClass.js export defaul ...

Is there a way to invoke a client-side function from the server?

Is there a way to display an alert at the top of the browser if the SQL query returns empty results? I tried using the "alert" function, but I'm struggling with customizing its appearance. I have a function in my HTML code that triggers an alert, but ...

What is the best way to halt the parcel/babel/typescript process when encountering compilation errors or warnings?

index.jsx import React from 'react' import ReactDOM from 'react-dom' import Home from "./home"; const x:number = "aaa" const x:number = "aaa" const x:number = "aaa" ReactDOM.render(<Home/>, document.getElementById('root&ap ...

Angular 4's customizable features for loading dynamic classes

Our application features a KeypadComponent that showcases keyboard layout based on JSON input, for example: {'Q', 'W', 'E', 'R'...}. Currently, we have approximately 100 predefined keyboard layouts. However, the pot ...

What is the proper way to specify a generic type as a parameter in TypeScript?

I have devised a basic Form class using TypeScript: class Form<FormData> { protected data: FormData; constructor(data: FormData) { this.data = data; } } To ensure the form receives specific data upon instantiation, I included a ...

Vue project encountering TypeScript error: Module not found

In my Vue project, I am encountering an issue while using TypeScript. Whenever I try to import a .vue file, I encounter a 'cannot find module...' error. https://i.sstatic.net/jUPGe.jpg The strange thing is that the intellisense only displays t ...

A guide on incorporating typings for d3-tip in TypeScript 2.0

Seeking to implement tooltips in my charts using the d3-tip library. After installing typings for d3-tip in Typescript 2.0: npm install @types/d3-tip --save The typings appear in my package.json: "dependencies": { "@types/d3": "^4.7.0", "@types/d3- ...

Should original Typescript code be stored in the published node_module library or not?

When developing a node module in Typescript and preparing it for publishing, I have the option to publish only the transpiled (obfuscated) code contained in the /dist folder. Alternatively, I can also choose to publish the original code found in either the ...

How can I best declare a reactive variable without a value in Vue 3 using TypeScript?

Is there a way to initialize a reactive variable without assigning it a value initially? After trying various methods, I found that using null as the initial value doesn't seem to work: const workspaceReact = reactive(null) // incorrect! Cannot pass n ...

Angular unit testing encounters an error when using the DynamicTestModule

I am currently setting up a unit testing environment using Karma and Jasmine. Here is an example: describe('ProfileListComponent', () => { let component: ProfileListComponent; beforeEach(async(() => { TestBed.configureTestingModule({ ...

React TS implementation of radial animated focus effect using mask-image technique

I am attempting to replicate the Radial animated focus effect using mask-image: Codepen. While I could simply copy and paste the CSS into a .css file, I want to achieve the same outcome with a styled component. I have defined the CSS within my styled compo ...

Utilize Firebase Realtime Database to generate new data entries using triggers

Hey there, to all the amazing folks at stackoverflow who have been supporting me over the years, I have a new question for you! I've been delving into Android programming for quite some time now and I enjoy exploring different ways to optimize apps. ...

Activate the event when the radio button is changed

Is there a way to change the selected radio button in a radio group that is generated using a for loop? I am attempting to utilize the changeRadio function to select and trigger the change of the radio button based on a specific value. <mat-radio-group ...

Issue with triggering angular function multiple times in certain conditions

Issue: Experiencing difficulties with Angular directive as it is being called multiple times, resulting in incorrect transaction outcomes and multiple entries on the Console screen. Desired Outcome: Ensure that the function executes only once. Sample cod ...

A guide on exposing TypeScript classes globally through a WebPack bundle in JavaScript

Currently delving into TypeScript, my aim is to gradually replace JS with TS. However, due to having numerous JS files, my strategy involves creating new classes in TS and incorporating them into my existing JS files for the time being. Eventually, I plan ...

Having Trouble with Ionic 2's Loading Controller

In my attempt to utilize the recently added LoadingController in this scenario: let loading=this.load.create({ content: "Connexion au serveur Migal en cours..." }); loading.present(); this.http.get(this.urlCheckerForm.value.migalUrl+'/action/Mobi ...