A JavaScript dependency without types is either an any, which defeats the point, or a declaration file, which takes ten minutes and only needs to describe what you use.
// types/legacy-widget/index.d.ts
declare module 'legacy-widget' {
export interface Options {
container: HTMLElement;
onSelect?: (id: string) => void;
}
export function mount(options: Options): void;
export function destroy(): void;
}
Describing only the surface actually called is the practical approach — a complete declaration for a large library is a project, and an incomplete one is useful immediately. Checking DefinitelyTyped first is worth the thirty seconds, since the @types package exists for most things by now. A declaration that is wrong is worse than none, because it moves the failure from the compiler to production, so it is worth verifying the signature against the library source rather than its README.