Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting declarations for library with multiple entry points

Tags:

typescript

Let's say I'm exporting a library with a file structure like

|__ src
| |__ index.ts
| |__ other-file.ts

And I'd like to consume it like

import { something } from 'library'
import { other } from 'library/other-file'

How should I structure the output in order to achieve that?

like image 420
wkrueger Avatar asked Apr 28 '26 20:04

wkrueger


1 Answers

How should I structure the output in order to achieve that?

|__ lib
| |__ index.js
| |__ index.d.ts
| |__ other-file.js
| |__ other-file.d.ts
|__ src
| |__ index.ts
| |__ other-file.ts

With tsconfig.json having outDir:lib/ declaration:true/ include:['src'].

Use will look like:

import { something } from 'library'
import { other } from 'library/lib/other-file'

More

  • Example Project
  • Library authoring guide
like image 75
basarat Avatar answered May 03 '26 02:05

basarat