mapbox / geojsonhint

IMPORTANT: This repo will be archived. Use @placemarkio/check-geojson instead
ISC License
258 stars 37 forks source link

Any chance for TypeScript or i18n support? #93

Open szulcus opened 1 year ago

szulcus commented 1 year ago

Like below

szulcus commented 1 year ago

Temporary workaround for TypeScript users (generated by Chat GPT v4):

Given the documentation you've provided, I can help you draft a type definition (index.d.ts) for the @mapbox/geojsonhint package. This will allow TypeScript users to use this package with type checking.

Here's a basic TypeScript declaration based on the documentation you provided:

declare module '@mapbox/geojsonhint' {

  interface ErrorHint {
    message: string;
    line: number;
    level?: 'message';
  }

  interface HintOptions {
    noDuplicateMembers?: boolean;
    precisionWarning?: boolean;
    ignoreRightHandRule?: boolean;
  }

  function hint(data: string | object, options?: HintOptions): ErrorHint[];

  export = {
    hint
  };
}

Please note the following:

  1. This declaration assumes that the only exported function is hint based on the provided documentation.
  2. The ErrorHint interface represents the errors returned from the hint function.
  3. The HintOptions interface captures the optional configuration for the hint function.
  4. As with any TypeScript definition file, this should be treated as a starting point. Depending on the full functionality of the module or specific use cases, adjustments might be necessary.

To use these type definitions:

  1. Save the above code in a file named index.d.ts in your project.
  2. Ensure TypeScript can find this file. Typically, placing it in the root directory or within a types directory at your project root is sufficient. You can then reference it in your tsconfig.json if needed.

Remember that if the @mapbox/geojsonhint library updates or has additional functionalities not covered in the documentation you provided, the type definition might need updates.