• Error
  • Reported by the type checker

TS7016

Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type.

A JavaScript package has no type declarations, so its imports would be `any`. Install its `@types` package or declare the module.

What it means

An import resolved to a JavaScript file, but no declaration file (.d.ts) was found for it, so under noImplicitAny everything it exports would be any. This is common with older npm packages that don't ship types.

Example

index.ts
import { slugify } from "slugger";
export const s = slugify("Hello");
node_modules/slugger/index.js
exports.slugify = (s) => s.toLowerCase();
node_modules/slugger/package.json
{ "name": "slugger", "main": "index.js" }
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,25): error TS7016: Could not find a declaration file for module 'slugger'. 'node_modules/slugger/index.js' implicitly has an 'any' type.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Install the community types if they exist: npm i -D @types/<package>.
  • Otherwise add a declaration in your project, for example in types/<package>.d.ts: declare module "<package>" { export function f(x: string): number; }.
  • A shorthand declare module "<package>"; silences it but makes every import any.