Turfjs / Turfjs/turf

segmentEach callback args typed as nullable

Open
#2,706 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

typescript
Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

The TypeScript types for segmentEach in @turf/meta have all the arguments to the callback as nullable, but it doesn't appear from either the docs or the code that they can ever be null. This makes it necessary to write pointless checks for undefined to get my code to typecheck.

Using Turf 7.1.0; this is still the case in latest master.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/turf-meta/index.d.ts#L228 and read the segmentEach type alongside the linked implementation and documentation. Confirm whether the callback arguments can be null, then update the type declaration so it matches the observed API and verify that TypeScript consumers no longer need unnecessary undefined checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.