Skip to content

Conversation

@smallsaucepan
Copy link
Member

Introduced TSTyche for type checking and to guard against unintentional API changes. For example, a test like this would have caught #3006

This is a second PR to compare with a similar solution using tsd #3015

Please provide the following when creating a PR:

  • Meaningful title, including the name of the package being modified.
  • Summary of the changes.
  • Heads up if this is a breaking change.
  • Any issues this resolves.
  • Inclusion of your details in the contributors field of package.json - you've earned it! 👏
  • Confirmation you've read the steps for preparing a pull request.

…al API changes. For example, a test like this would have caught Turfjs#3006
@smallsaucepan
Copy link
Member Author

Example error output:

> @turf/line-offset@7.3.3 test:types /Users/james/turf/packages/turf-line-offset
> tstyche

···· TSTyche 6.2.0 at /Users/james/turf/packages/turf-line-offset

uses TypeScript 5.8.3 with ./tsconfig.json

fail ./test/types.tst.ts

Error: Type 'Feature<LineString, { [name: string]: any; } | null> | Feature<MultiLineString, { [name: string]: any; } | null>' is not the same as type 'Feature<LineString, GeoJsonProperties>'.

  34 |  * broadened the return type which is likely to be a breaking change.
  35 |  */
  36 | expect(lineOffset(line, 50)).type.toBe<Feature<LineString>>();
     |                                        ~~~~~~~~~~~~~~~~~~~
  37 | expect(lineOffset(multiLine, 50)).type.toBe<Feature<MultiLineString>>();
  38 |

       at ./test/types.tst.ts:36:40

Error: Type 'Feature<LineString, { [name: string]: any; } | null> | Feature<MultiLineString, { [name: string]: any; } | null>' is not the same as type 'Feature<MultiLineString, GeoJsonProperties>'.

  35 |  */
  36 | expect(lineOffset(line, 50)).type.toBe<Feature<LineString>>();
  37 | expect(lineOffset(multiLine, 50)).type.toBe<Feature<MultiLineString>>();
     |                                             ~~~~~~~~~~~~~~~~~~~~~~~~
  38 |

       at ./test/types.tst.ts:37:45

Targets:    1 failed, 1 total
Test files: 1 failed, 1 total
Assertions: 2 failed, 5 passed, 7 total
Duration:   1.5s

Copy link
Collaborator

@mfedderly mfedderly left a comment

Choose a reason for hiding this comment

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

This PR seems pretty reasonable as well. I'm swayed by the argument that tsd is relatively unmaintained and tstyche is the replacement. It also doesn't ship as a dependency to our users, so worst case we just have to rework Turf itself. It seems like most of these libraries are standardizing around pretty similar APIs so worst case we can probably translate to another tool later if we have to.

@smallsaucepan smallsaucepan merged commit 1fed227 into Turfjs:master Feb 8, 2026
4 checks passed
@mrazauskas
Copy link

Thanks. I appreciate your choice! Please ping me if there are any questions in the future.

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.

3 participants