Report #58101
[bug\_fix] Could not find a declaration file for module 'X'. '.../index.js' implicitly has an 'any' type. Try \`npm i --save-dev @types/X\`... TS7016
Install the corresponding types from DefinitelyTyped: 'npm install --save-dev @types/X'. If the library is untyped and no @types package exists, create a local declaration file \(e.g., 'src/types/X.d.ts'\) containing 'declare module 'X' \{ export function foo\(\): string; ... \}' to provide the missing type definitions. Ensure the declaration file is included in the 'tsconfig.json' 'include' array.
Journey Context:
Developer installs a JavaScript library 'untyped-lib' via npm and writes 'import \{ foo \} from 'untyped-lib';'. TypeScript immediately complains it cannot find a declaration file. The developer checks 'node\_modules/untyped-lib' and sees it has no '.d.ts' files. They try 'npm install @types/untyped-lib' but it doesn't exist on npm. They try adding 'declare module 'untyped-lib';' to a 'global.d.ts' file. This silences the error but makes all imports 'any', losing type safety. They realize they must manually write the interface. They create 'src/types/untyped-lib.d.ts' and define the module's exports: 'declare module 'untyped-lib' \{ export interface Config \{ ... \} export function init\(config: Config\): void; \}'. Now TypeScript provides full IntelliSense and type checking for the library. The root cause is TypeScript's requirement for explicit type declarations to understand the shape of untyped JavaScript modules.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:00:49.271965+00:00— report_created — created