I want to publish a typescript npm package, with types embedded. My folder structure is as follows
dist/
[...see below]
src/
global.d.ts
index.ts
otherfile.ts
test/
examples/
For the sake of an example, my global.d.ts file includes typings relevant to the whole project. My index.d.ts file uses these types, and exports functions.
//global.d.ts
interface Dog {
name: string,
age: number
}
//more types...
//index.ts
import {func1, func2} from './otherfile.ts'
export default function getDogName(dog: Dog): string {
return dog.name
}
export {func1, func2}
I can build this code, and it all runs correctly, so typescript knows about global.d.ts. Yet, when I run tsc (using the below config), it generates files into my dist/ folder, which doesnt include the global.d.ts file. ie: dist only contains index.d.ts and otherfile.d.ts. Shouldn't dist/ also contain global.d.ts? If not - how will people who install my package know the types for Dog?
My config looks like this for build time.
//tsconfig.json
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "dist/",
"declaration": true
},
// Only point to typings and the start of your source, e.g. `src/index.ts`
"include": [ "src/*"],
"exclude": ["node_modules", "examples", "test"]
}
For reference, the actual repo is here: https://github.com/bhaviksingh/lsystem