RedditPP Mascot

RedditPP

r/typescript • … • u/react_dev

How do I publish a library with multiple index.d.ts?

So I want to publish a components library where the consumer can use components from the main index or a sub-folder where legacy components are stored.

`import Button from "my-library"`

`import Button from "my-library/legacy"`

In tsconfig.json, I have it generate the types:

"declaration": true /* Generates corresponding '.d.ts' file. */, "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */, "declarationDir": "typing",

So it generates a typings folder with 2 index.d.ts files, one in root and one in \`legacy\` folder.

My question is I could only define one entry point in the \`types\` field in package.json. How do I include the other typing file in the \`legacy\` subfolder? Is this where I use a triple slash directive?

Thanks!

— 0