Lib mode should export types
See original GitHub issueClear and concise description of the problem
To provide a better experience for our users, lib mode should automatically generate TypeScript definitions, and not require additional setup.
Suggested solution
Alternative
Workarounds:
-
@keelii https://github.com/vitejs/vite/issues/2989#issuecomment-820914375
{ "build:types": "tsc -m amd -t ESNext -d --isolatedModules false --moduleResolution node --esModuleInterop --jsx react --outFile dist/index.js src/main.ts && rm -rf dist/index.js " }
-
@sanjade https://github.com/vitejs/vite/issues/2989#issuecomment-826064324
{ "build": "tsup index.ts --format esm,cjs,iife --dts --minify" }
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Reactions:13
- Comments:13 (6 by maintainers)
Top Results From Across the Web
TypeScript library tips: Rollup your types! | by Martin Hochel
When authoring a TypeScript library make sure to follow best industry practices like shipping smallest possible files by rollup-ing your ...
Read more >Export and publish all types and interfaces in Typescript
I get autocomplete for mylib because it is exported. My question is how can I see all the types and interfaces of mylib...
Read more >Documentation - Modules - TypeScript
Each module can optionally export a default export. Default exports are marked with the keyword default ; and there can only be one...
Read more >How to re-export types for users in a library? : r/typescript
The "Documents" variable only contains one property "default", which is just the default export. Why is that? How can I import all the ......
Read more >Tlbexp.exe (Type Library Exporter) - .NET Framework
You can export a type library from an assembly that references assemblies that were imported using Tlbimp.exe. See the examples section below.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I made a plugin
vite-plugin-dts
to generate d.ts for lib.A direct dependency isn’t required, since we can use resolve to find
typescript
from the project root. Regardless, we still think this use case should be handled in a userland plugin, if anything. We’d like to avoid the maintenance burden and subtle complexities introduced by declaration bundling. Someone in the community will hopefully create a plugin if the mentioned workarounds are insufficient.