Masth0 / ScratchCard

ScratchCard is a js lib to simulated a scratchcard in browser with html5 and canvas.
MIT License
153 stars 49 forks source link

Error when importing { SCRATCH_TYPE, ScratchCard } #46

Closed daniel-agouveia closed 1 year ago

daniel-agouveia commented 1 year ago

I noticed this error Could not find a declaration file for module 'scratchcard-js'. 'directory/node_modules/scratchcard-js/build/scratchcard.min.js' implicitly has an 'any' type.

This happens when trying to import { SCRATCH_TYPE, ScratchCard } from 'scratchcard-js'; in Angular 13, the only workaround I found was to add "noImplicitAny": false in my tsconfig.json file inside the compiler options. Why is this happening? All other libraries work without issues.

Masth0 commented 1 year ago

I have added the declarations files in latest version.

In your tsconfig.app.json, add the paths property to the compilerOptions.

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "paths": {
      "scratchcard-js": ["./node_modules/scratchcard-js/types/scratchcard-js.d.ts"]
    },
  },
  "files": [
    "src/main.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}
daniel-agouveia commented 1 year ago

I have added the declarations files in latest version.

In your tsconfig.app.json, add the paths property to the compilerOptions.

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "paths": {
      "scratchcard-js": ["./node_modules/scratchcard-js/types/scratchcard-js.d.ts"]
    },
  },
  "files": [
    "src/main.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

Thank you for reply!