aa-js icon indicating copy to clipboard operation
aa-js copied to clipboard

ts7016 error - cannot resolve types between index.d.ts and package.json

Open sxflynn opened this issue 8 months ago • 2 comments

I performed an npm install aa-js into my Typescript project and VS Code is giving this linting error on the import statement.

I followed the example in the readme and started by importing julian days.

import { juliandays, Earth } from 'aa-js'

const jd = juliandays.getJulianDay(new Date())

Under the 'aa-js' it provides an error and this is the message:

Could not find a declaration file for module 'aa-js'. '/[appname]/node_modules/aa-js/dist/aa-js.js' implicitly has an 'any' type. There are types at '[appname]/node_modules/aa-js/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'aa-js' library may need to update its package.json or typings. ts(7016)

For example, this code does work:

import {
  Sun,
  coordinates,
  type JulianDay,
  GeographicCoordinates,
  HorizontalCoordinates,
  EquatorialCoordinates,
} from "aa-js";

export const calcSunAltitude = (
  jd: JulianDay,
  coord: GeographicCoordinates
): HorizontalCoordinates => {
  const sunGeoEquCoord: EquatorialCoordinates =
    Sun.getGeocentricEquatorialCoordinates(jd);
  return coordinates.transformEquatorialToHorizontal(jd, sunGeoEquCoord, coord)
    .altitude;
};

Although I am able to compile and run the web application with this error, I am not provided with any Typescript intellisense or typechecking.

sxflynn avatar Jun 16 '24 01:06 sxflynn