Report #88826
[bug\_fix] Could not find a declaration file for module 'untyped-lib'. '.../index.js' implicitly has an 'any' type. \(TS7016\)
Install the corresponding @types package \(npm install --save-dev @types/untyped-lib\) if available on DefinitelyTyped; otherwise, create a local declaration file \(e.g., src/types/untyped-lib.d.ts\) containing declare module 'untyped-lib'; or detailed type definitions.
Journey Context:
You install an internal company library published only as CommonJS JavaScript. Upon importing it \(import \{ parse \} from 'company-parser';\), TypeScript throws TS7016. You check node\_modules and see the package has no .d.ts files. You first try to install @types/company-parser, but it doesn't exist on DefinitelyTyped. You consider using // @ts-ignore, but that propagates any downstream, breaking autocomplete. You create a file src/types/company-parser.d.ts and write declare module 'company-parser' \{ export function parse\(input: string\): number; \}. Upon saving, the error vanishes and you get full autocomplete. The fix works because TypeScript's module resolution looks for .d.ts files alongside imported JS files or in typeRoots; by providing a declaration file, you manually supply the missing type metadata the compiler needs for type checking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:40:58.536811+00:00— report_created — created