Missing type definition information in VS Code when own Node.js package is published on NPM

Issue

I cannot figure out why, once my own efficy-enterprise-api NPM package is published, the type definitions (used by VS Code intellisense) are not available anymore compared to locally referencing the package, e.g. import { CrmRpc} from "../efficy-enterprise-api";

Package is written in native ES6 (using .mjs extension) with JSDoc annotations.

No issue when locally referencing the Node.js package:

import { CrmRpc } from "../efficy-enterprise-api";

const crm = new CrmRpc(); // Type definition CrmRpc is accessible
const Cont = crm.openEditObject("Cont", 0); // Type definition "EditObject" is accessible

Missing type definitions when referencing the published package:

import { CrmRpc} from "efficy-enterprise-api";

const crm = new CrmRpc(); // Type definition CrmRpc is accessible
const Cont = crm.openEditObject("Cont", 0); // Type definition "EditObject" is not accessible anymore...

Solution

I deduced the issue to the usage of the separated ./@typings folder for the generate .mts and .mts.map files. I was unable to find a functional configuration of package.json to point to these multiple generated files (not only index.mjs)

By running typescript tsc without outDir=@typings configured, the typings are fully functional.

Answered By – Pauwris

Answer Checked By – Willingham (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.