Reputation: 5923
I have a TypeScript library that I want to export for other JS/TS developers to use. As a benefit for users of my library, I'd like to export the types as well. How do I do that? I.e. how do I export a index.d.ts
type declaration file?
I've looked at the TypeScript docs, but they seem to talk about writing explicit type declarations, whereas I want to automatically export type declarations when running npx tsc
.
Here's the tsconfig.json
:
{
"compilerOptions": {
"lib": ["ES2019"],
"module": "es6",
"target": "es5",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"sourceMap": true,
"outDir": "build",
"strict": true,
"noImplicitAny": true,
},
"include": ["./**/*.ts"],
"exclude": ["node_modules", ".vscode", "test"]
}
Upvotes: 1
Views: 52