ianengelbrecht / geo-coordinates-parser

A Javascript function for reading a variety of coordinate formats and converting to decimal numbers. Builds on other efforts by returning the verbatim coordinates and the decimal coordinates all in one object.
MIT License
38 stars 9 forks source link

mark convert's second parameter as optional for typescript definition generation #17

Closed Geam closed 7 months ago

Geam commented 7 months ago

Hello,

As I was using this package with typescript I realized there is an error in the typescript definition of convert function : as per the readme.md and the function's code it can accept only one parameter but the typescript definition requires two parameters.

This pr fix the jsdoc that is used to generate the typescript definition to make second parameter optional.

ianengelbrecht commented 7 months ago

Thank you for this, much improved!

Geam commented 7 months ago

You're welcome and thank you for maintaining this library.

That being said, I installed the 1.6.5 and I still have the old typescript definition

dist/mjs/convert.d.ts

export default converter;
/**
 * Function for converting coordinates in a variety of formats to decimal coordinates
 * @param {string} coordsString The coordinates string to convert
 * @param {number} decimalPlaces The number of decimal places for converted coordinates; default is 5
 * @returns {object} { verbatimCoordinates, decimalCoordinates, decimalLatitude, decimalLongitude }
 */
declare function converter(coordsString: string, decimalPlaces: number): object;
declare namespace converter {
    export { to };
}
declare const to: Readonly<{
    DMS: "DMS";
    DM: "DM";
    DD: "DD";
}>;

whereas when I built it I end up with

dist/mjs/converter.d.ts

export default converter;
/**
 * Function for converting coordinates in a variety of formats to decimal coordinates
 * @param {string} coordsString The coordinates string to convert
 * @param {number} [decimalPlaces] The number of decimal places for converted coordinates; default is 5
 * @returns {{verbatimCoordinates: string, decimalCoordinates: string, decimalLatitude: string, decimalLongitude: string, closeEnough: function(string): boolean, toCoordinateFormat: toCoordinateFormat}}
 */
declare function converter(coordsString: string, decimalPlaces?: number | undefined): {
    verbatimCoordinates: string;
    decimalCoordinates: string;
    decimalLatitude: string;
    decimalLongitude: string;
    closeEnough: (arg0: string) => boolean;
    toCoordinateFormat: typeof toCoordinateFormat;
};
declare namespace converter {
    export { to };
}
import toCoordinateFormat from './toCoordinateFormat.js';
declare const to: Readonly<{
    DMS: "DMS";
    DM: "DM";
    DD: "DD";
}>;
ianengelbrecht commented 7 months ago

I forgot I had a build step for this package. Now run and should be working. Please try again.

Geam commented 7 months ago

It's all good, many thanks ! By the way, in case you didn't know, in the package.json in scripts you can add "prepack": "npm run build" that way the build will be re-run before each npm pack

{
  "scripts": {
    "build": "rd /s /q dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && fixup.bat",
    "prepack": "npm run build",
    "test": "node test.js"
    }
  }
ianengelbrecht commented 7 months ago

I did not know about that! You just made my life easier:-D

Ian Engelbrecht Digitization Coordinator Natural Science Collections Facility South Africa https://nscf.org.za/ https://nscf.org.za/ +27 82 763 4596 i @.>@. / @.***

On Wed, 13 Mar 2024 at 14:13, Marc Delage @.***> wrote:

It's all good, many thanks ! By the way, in case you didn't know, in the package.json in scripts you can add "prepack": "npm run build" that way the build will be re-run before each npm pack

— Reply to this email directly, view it on GitHub https://github.com/ianengelbrecht/geo-coordinates-parser/pull/17#issuecomment-1994244749, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACH3QIYLNLNABQYZRVVAQLDYYA7HHAVCNFSM6AAAAABESQFVEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJUGI2DINZUHE . You are receiving this because you modified the open/close state.Message ID: @.***>