Skip to content

Could not find a declaration file for module 'cal-heatmap' #537

@askme23

Description

@askme23

Hey, I am trying to integrate cal-heatmap with nextjs but have an error with importing library:

Could not find a declaration file for module 'cal-heatmap'. '/Users/ruslangorelov/projects/life-history/front/node_modules/.pnpm/[email protected]/node_modules/cal-heatmap/dist/cal-heatmap.js' implicitly has an 'any' type.
Try npm i --save-dev @types/cal-heatmap if it exists or add a new declaration (.d.ts) file containing declare module 'cal-heatmap';

My component:

import Image from "next/image";

import CalHeatmap from 'cal-heatmap';

function CalendarHeatMap() {
  const d = new CalHeatmap();
  d.paint({});
  
  return (
    <div id="cal-heatmap"></div>
  )
}

export default function Home() {
  return (
    <div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
      <CalendarHeatMap />
    </div>
  );
}

and tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "Node16",
    "moduleResolution": "node16",
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

I was trying to play with some options in tsconfig, but it wasn't successful. Help me find out what is the problem here )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions