Home > Enterprise >  Typescript: dependency doesn't seem to be fulfiled
Typescript: dependency doesn't seem to be fulfiled

Time:03-16

Compiling an Angular project, I'm getting an error from a package I installed with NPM:

node_modules/astrocite-ris/index.d.ts:36:39 - error TS2503: Cannot find namespace 'CSL'.

The package, Astrocite, includes the subpackage astrocite-ris. I've included it in the package.json as "astrocite": "^0.16.4", and imported it into a service with:

import { parse } from 'astrocite-ris';

VSCode shows the error in the index.d.ts

CodePudding user response:

The typings for astrocite-ris seem a bit iffy. The package is written in TypeScript, but the typings come from a manually written 3-year old index.d.ts. When dealing with type errors in packages themselves, you can choose to disable type checking inside node_modules by adding "skipLibCheck": false to the compilerOptions in your tsconfig.json (docs). However, in this case, you can also fix the problem by including

import 'csl-json'

in one of your source files, as this will declare the global CSL namespace. It's also a good idea to do an npm i -D csl-json to explicitly include the package in your dev-dependencies. Utimately, the problem will need to be fixed by the developer of astrocite-ris though, so you might want to open an issue in https://github.com/dsifford/astrocite.

  • Related