Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Meta] Improve typescript support #2155

Open
twelch opened this issue Jul 25, 2021 · 4 comments
Open

[Meta] Improve typescript support #2155

twelch opened this issue Jul 25, 2021 · 4 comments
Assignees
Milestone

Comments

@twelch
Copy link
Collaborator

twelch commented Jul 25, 2021

Goals:

Related tickets:

@twelch twelch added this to the 7.0.0 milestone Jul 26, 2021
@twelch twelch self-assigned this Jul 28, 2021
@robinsummerhill
Copy link

Hi. Any progress on this? The incompatibility between turf/geojson/mapboxgl is a continual sticking point for us.

@david-morris
Copy link

I'd like to add that this library is type-incompatible with itself because of union return types. Here's an example of how to take a list of polygons and convert them to a collection of lines:

featureCollection(
    places.flatMap(
      ({ geometry, name }) =>
        (polygonToLine(geometry, { properties: { name } }) as FeatureCollection)
          .features
    )
  )

It requires a type assertion.

Presumably, that's because certain arguments to polygonToLine would cause switches between feature collections and feature output; otherwise this type should just get narrowed.

If it is because of a switch, it might make sense to make functions like this generic. A generic type could be used to restrict the allowable input options (specifically those output switches) and narrow the output type.

Generic typing would also need to be documented.

@smallsaucepan smallsaucepan modified the milestones: v7, v8 Dec 15, 2023
@alamenai
Copy link

Any updates. I want to use Turf Mask but it does not support TypeScript.

@smallsaucepan
Copy link
Member

Hi @alamenai Try the latest 7.0.0-alpha.114. Typescript support is be much improved in v7.

@smallsaucepan smallsaucepan added this to the 7.0.0 milestone Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants