Skip to content

Conversation

@bankjirapan
Copy link

This PR introduces full TypeScript type declarations for the map instance and related Longdo Map functionalities. Previously, when using TypeScript, developers encountered the following issue:

function onMapLoad(map) {
  map.Event.bind(EventName.Click, () => {
    console.log('object');
  });
}

TypeScript would throw:
Parameter 'map' implicitly has an 'any' type. ts-plugin(7006)

Screenshot 2568-11-20 at 14 47 05

And using any is not allowed under typical linting rules:
Unexpected any. Specify a different type. eslint@typescript-eslint/no-explicit-any

What’s Included

  • Added explicit Map type and related type definitions.
  • Added JSDoc comments for better IntelliSense and hover documentation.
  • Improved overall developer experience when using this library with TypeScript.
  • EventName enums are now fully typed and autocompletable.

Usage Example

import { type Map, EventName } from "longdo-map-vue";  // Import the Map type
import { useLongdoMap, LongdoMap } from "longdo-map-vue";

const mapReady = ref(false);

function onMapLoad(map: Map) {
  map.Event.bind(EventName.Click, () => {
    console.log('object');
  });
}

Can now use Longdo Map events via:

EventName.<Event>

Instead of the previous:

window.longdo.EventName.<Event>

Developers using TypeScript will now get:

  • Proper type checking
  • Better IntelliSense
  • Cleaner and safer code
  • No more lint errors regarding implicit any

Images

  1. Type safe
Screenshot 2568-11-20 at 14 28 56 Screenshot 2568-11-20 at 14 20 03
  1. JSDoc
    Can view example code by hovering over each property.
Screenshot 2568-11-20 at 14 28 49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant