I am trying to publish a typescript library. It is not clear to me how to expose all the types and interfaces. Here is my setup:
mylib
├──src
│ ├──types
| | └──mytypes.ts
│ └──index.ts
├──package.json
└──tsconfig.json
//index.ts
import {MyInterface} from './types/mytypes.ts';
const my_main_name = {
myfunc: function(param1:MyInterface):void{
console.log(param1.a);
}
}
//mytypes.ts
export interface MyInterface {
a:string
}
I am generating declaration files by setting tsconfig.json param "declaration":"true".
Now I want to use this libraries as dependency of another one.
mylib
yrlib
├──src
│ └──index.ts
├──package.json
└──tsconfig.json
//yrlib/package.json
{
...
"dependencies":{
"mylib":"file:../mylib/"
}
}
//yrlib/src/index.ts
import * as mylib from 'mylib';
let a:mylib.MyInterface = ...
// ~~ Namespace has no export member for MyInterface
I get autocomplete for mylib because it is exported.
My question is how can I see all the types and interfaces of mylib module inside yrlib?
Since they can be hundreds and in all different files and folders.
Should I export all of them one by one? What is the best practice? Is there a way to export all types at once?
And how "typying":"dist/index.d.ts" in package.json fits in all this? Should be all the types in one file? Why Typescript doesn't generate this file?
Should I use a namespace that contain everything? I cannot find a full explanation on this topic.