Typescript definitions in separate 'types' dir for multiple entry points

Viewed 539

I am working on type definitions for the javascript library, btw I don't know typescript and have no resources to learn it. So, for now, I rely on VS Code and its autocompletion/hint feature based on builtin typescript.

js library/package exposes multiply entry points: main (not index.js) file and a lot of separate methods for cherry-picking.

So when I place my d.ts files with same names right into root directory - everything works (in VS Code at least)

But when I try to move all these files to separate sub-directory and set "types" property of package.json for my main entry point - it works only for this main function. VSCode cannot find the rest of defs for other files.

There are already a lot of files in root dir, so I don't want to double this number by keeping def files in root dir.

Is there any way to do this? Everything I found is this discussion with no good answer.

Here is the current state In root dir, there is a main module deepdash.js defs lives in es/deepdash.d.ts in package.json

{
  "name": "deepdash",
  "version": "4.5.5",
  "description": "➔ eep standalone lib / odash extension: ✓ eachDeep ✓ filterDeep ✓ mapDeep ✓ reduceDeep ✓ pickDeep ✓ omitDeep ✓ keysDeep ✓ index ✓ condenseDeep ⋮ Parents stack ⋮ Circular check ⋮ Leaves only mode ⋮ Children mode ⋮ cherry-pick ⋮ esm",
  "main": "deepdash.js",
  "module": "es/standalone.js",
  "types": "es/deepdash.d.ts",
  ...

In esm version of the package (published from 'es' dir) I left all the defs right in the root dir, so everything works there.

So is there any way? Copying all d.ts files on the npm 'install' phase? something else?

0 Answers
Related