Report #90330
[bug\_fix] Could not find a declaration file for module 'untyped-npm-package'. '.../index.js' implicitly has an 'any' type.
Create a type declaration file \(e.g., 'src/types/untyped-npm-package.d.ts'\) containing 'declare module 'untyped-npm-package';' or 'declare module 'untyped-npm-package' \{ export function parse\(data: string\): any\[\]\[\]; \}'. Root cause: TypeScript requires type definitions for all imported modules. When a package doesn't ship with .d.ts files and there's no @types package available in node\_modules, TypeScript cannot determine the module's shape and defaults to 'any', which is disallowed under 'noImplicitAny' or 'strict' mode. Declaring the module provides the minimal type information needed to satisfy the compiler.
Journey Context:
You just installed a small utility package 'js-csv-parser' from npm that hasn't been updated in years. You import it: 'import \{ parse \} from 'js-csv-parser';'. TypeScript immediately underlines the import with 'Could not find a declaration file for module 'js-csv-parser'. '.../node\_modules/js-csv-parser/index.js' implicitly has an 'any' type.' You try 'npm install --save-dev @types/js-csv-parser' but npm returns 404 - the package is too obscure. You consider adding '// @ts-ignore' above the line, but that disables type checking for that import entirely. You search for 'TypeScript could not find declaration file' and find the official TypeScript handbook suggesting to create a '.d.ts' file. You create 'src/types/js-csv-parser.d.ts' \(or any .d.ts file in your project\) with the content: 'declare module 'js-csv-parser' \{ export function parse\(data: string\): any\[\]\[\]; \}'. The error disappears immediately. If you just want to silence it quickly without proper types, you can write just 'declare module 'js-csv-parser';' which treats everything as 'any'. The fix works because TypeScript's module resolution looks for .d.ts files to satisfy import type requirements. By declaring the module, you're telling the compiler 'this module exists and has this shape', satisfying the type checker even though the original package lacks types.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:12:47.254926+00:00— report_created — created