janrg / MeeusSunMoon

JavaScript module to calculate times for sunrise, solar noon, and sunset, as well as moon phases based on "Astronomical Algorithms" by Jean Meeus
MIT License
31 stars 9 forks source link

Add typings #5

Open muuvmuuv opened 6 years ago

muuvmuuv commented 6 years ago

Could you provide Typescript typings so we can take advantage of intellisense from our editors?

janrg commented 6 years ago

I'm unclear as to the degree of benefit given the very limited interface of the library in which all outputs are moment objects and all inputs either moment objects or numbers. Could you elaborate where you think this would significantly increase convenience?

muuvmuuv commented 6 years ago

In my case, I could not use your project because I always get a typing error.

janrg commented 6 years ago

You get an error that prevents you from using the library because typing information is not provided? That seems very strange to me. Could you provide some more details so I can see if I can reproduce what's going on there?

muuvmuuv commented 6 years ago

Sure! So this is the complete error I get from VS Code:

[ts]
Could not find a declaration file for module 'meeussunmoon'. '/Users/marvinheilemann/Documents/Projects/VSCode/vscode-sundial/node_modules/meeussunmoon/dist/meeussunmoon.min.js' implicitly has an 'any' type.
  Try `npm install @types/meeussunmoon` if it exists or add a new declaration (.d.ts) file containing `declare module 'meeussunmoon';`

This is the test code:

import MeeusSunMoon from 'meeussunmoon';

MeeusSunMoon.options({
  roundToNearestMinute: true, // default: false
  returnTimeForPNMS: true, // default: false
  dateFormatKeys: {'**': '‡', '--': '†'} // default {'**': '‡', '--': '†'};
});

I have no declaration.d.ts file or anything else. The project where I tested this is: VS Code Sundial