0

When building an angular library into an NPM package, the RXJS for operator directs to the full path on the computer in the declaration file (.d.ts)

This build of the package succeeds, but when implementing it into an application it will throw an error.

node_modules/@essent/ns-mobile-contract-ids/lib/contract-ids.service.d.ts(7,43): error TS1144: '{' or ';' expected.

node_modules/@essent/ns-mobile-contract-ids/lib/contract-ids.service.d.ts(12,7): error TS1005: '(' expected.

The file I'm building contains the following code, where the rxjs import refers to rxjs/index.d.ts in node_modules

import {of} from "rxjs";
return of({
                    agreementId: 1,
                    premiseId: 500,
                    connectionEANs: this.createConnectionEANsMap("01", "02"),
                    partnerId: 2
                });

When build, the contract-ids.service.d.ts contains this:

 constructor(http: HttpClient);
getContractIds(apiUrl: string): import("../../../../../../../../../Users/milansteenwinkel/Desktop/Projects/ns-mobile-library/node_modules/rxjs/internal/Observable").Observable<{
    agreementId: number;
    premiseId: number;
    connectionEANs: Map<string, string>;
    partnerId: number;
}>;

This does not happen with other imports from node_modules.

1 Answers1

0

Method needed a type definition for it to correctly create the declaration file. Added Observable as type.