As I develop a Typescript component library, the API consists of two named exports: the component itself and a helper function to create an object for passing as a prop. The process is straightforward.
For this library, I utilize an index.ts
file as the main entry point.
import Component from './Component';
import { helperFunc } from './helperFunc';
export { helperFunc, Component };
In addition, the component will also import a function like the one below from a file called internal.ts
export function foo(bar: string): string { ... }
The goal here is to prevent the generation of types for the internal file. This internal function won't be used or required by the end user; it's intended for internal use only.
The focus should be on generating and distributing types specifically for the exported code - in this case, helperFunc
and Component
, without creating types for anything other than those two elements. It's simply unnecessary.