0

I have a node.js project. Moved some code from an other Next.js / React /Typescript project. Got this error:

/Users/kukodajanos/Workspace/Tikex/typescript-starter/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/index.ts:477:12 - error TS2304: Cannot find name 'CanvasRenderingContext2D'.

CanvasRenderingContext2D is not found, though it is in node_modules, in

/node_modules/typescript/lib/li.dom.d.ts.

What is the problem?

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "lib": ["es6"],
    "allowJs": true,
    "outDir": "build",
    "rootDir": "src",
    "strict": true,
    "noImplicitAny": true,
    "esModuleInterop": true,
    "resolveJsonModule": true
  }
}

index.ts is quite long, but thi is the start of the method:

const getLines = (
  context: CanvasRenderingContext2D | SKRSContext2D,
  text: string,
  textFont: string,
  maxTextWidth: number
) => {
János
  • 32,867
  • 38
  • 193
  • 353

0 Answers0