Skip to content

Include MultiLineString output type for greatCircle module#1928

Merged
mfedderly merged 3 commits intoTurfjs:masterfrom
kronick:kronick/fix-great-circle-types
Nov 17, 2020
Merged

Include MultiLineString output type for greatCircle module#1928
mfedderly merged 3 commits intoTurfjs:masterfrom
kronick:kronick/fix-great-circle-types

Conversation

@kronick
Copy link
Copy Markdown
Contributor

@kronick kronick commented Jul 14, 2020

This PR updates the Typescript type definitions and corresponding docs for the greatCircle function to include the possibility of returning a MultiLineString when the input spans the antimeridian. This is described as expected behavior in this issue. Without this fix, Typescript will return an error if you try to test, for example:

const greatCircleGeojson = greatCircle(start, end);
if(greatCircleGeojson?.geometry.type === "MultiLineString") {
 // ... handle this case
}

Typescript complains: This condition will always return 'false' since the types '"LineString" | undefined' and '"MultiLineString"' have no overlap.

@kronick kronick force-pushed the kronick/fix-great-circle-types branch from be22a50 to 2439f49 Compare July 16, 2020 01:40
Copy link
Copy Markdown
Member

@rowanwins rowanwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @kronick !

@kronick
Copy link
Copy Markdown
Contributor Author

kronick commented Jul 17, 2020

@rowanwins Thanks for the ✅ — will you handle merging this for the next release? Is there anything else I need to do?

@regileeso
Copy link
Copy Markdown

I'd love to see these changes in a new release as soon as possible 👍

@mfedderly mfedderly merged commit 1d33cbe into Turfjs:master Nov 17, 2020
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.

4 participants