question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript definitions

See original GitHub issue

Problem

At the moment you can install Typescript 2.0 definitions via npm install @types/turf.

However, not all of the definitions are defined and it can be overwhelming trying to manage a 1280+ LOC type definition.

Solution

I’m suggesting we host the Typescript type definitions within the Turf library instead of DefinitelyTyped.

By including a simple & minimalistic index.d.ts and test/types.ts within each package, the type definitions will be bundled with each namespace package.

By default index.d.ts will be automatically detected, however including "types": "index.d.ts" in the package.json is a good practice.

/// <reference types="geojson" />

/***
 * http://turfjs.org/docs/#point
 */
export type Point = Array<number>
export function point(coordinates: Point, properties?: Object): GeoJSON.Feature<GeoJSON.Point>;

To-Do

  • turf-along
  • turf-area
  • turf-bbox
  • turf-bbox-polygon
  • turf-bearing
  • turf-bezier
  • turf-buffer
  • turf-center
  • turf-center-of-mass
  • turf-centroid
  • turf-circle
  • turf-collect
  • turf-combine
  • turf-concave
  • turf-convex
  • turf-destination
  • turf-difference
  • turf-distance
  • turf-envelope
  • turf-explode
  • turf-flip
  • turf-helpers
  • turf-hex-grid
  • turf-idw
  • turf-inside
  • turf-intersect
  • turf-invariant
  • turf-isolines
  • turf-kinks
  • turf-line-distance
  • turf-line-slice
  • turf-line-slice-along
  • turf-meta
  • turf-midpoint
  • turf-nearest
  • turf-planepoint
  • turf-point-grid
  • turf-point-on-line
  • turf-point-on-surface
  • turf-random
  • turf-sample
  • turf-simplify
  • turf-square
  • turf-square-grid
  • turf-tag
  • turf-tesselate
  • turf-tin
  • turf-triangle-grid
  • turf-union
  • turf-within

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
bockoblurcommented, Dec 10, 2019

I don’t see anymore index.d.ts for the centroid package. Is this a missing ?

Any news on this? Just installed @turf/centroid 6.0.1 and types are missing…

5reactions
DenisCarrierecommented, Nov 28, 2016

🚀🚀 Woot! Completed all the Typescript definitions

packages/turf-along/index.d.ts
packages/turf-area/index.d.ts
packages/turf-bbox-polygon/index.d.ts
packages/turf-bbox/index.d.ts
packages/turf-bearing/index.d.ts
packages/turf-bezier/index.d.ts
packages/turf-buffer/index.d.ts
packages/turf-center-of-mass/index.d.ts
packages/turf-center/index.d.ts
packages/turf-centroid/index.d.ts
packages/turf-circle/index.d.ts
packages/turf-collect/index.d.ts
packages/turf-combine/index.d.ts
packages/turf-concave/index.d.ts
packages/turf-convex/index.d.ts
packages/turf-destination/index.d.ts
packages/turf-difference/index.d.ts
packages/turf-distance/index.d.ts
packages/turf-envelope/index.d.ts
packages/turf-explode/index.d.ts
packages/turf-flip/index.d.ts
packages/turf-helpers/index.d.ts
packages/turf-hex-grid/index.d.ts
packages/turf-idw/index.d.ts
packages/turf-inside/index.d.ts
packages/turf-intersect/index.d.ts
packages/turf-invariant/index.d.ts
packages/turf-isolines/index.d.ts
packages/turf-kinks/index.d.ts
packages/turf-line-distance/index.d.ts
packages/turf-line-slice-along/index.d.ts
packages/turf-line-slice/index.d.ts
packages/turf-meta/index.d.ts
packages/turf-midpoint/index.d.ts
packages/turf-nearest/index.d.ts
packages/turf-planepoint/index.d.ts
packages/turf-point-grid/index.d.ts
packages/turf-point-on-line/index.d.ts
packages/turf-point-on-surface/index.d.ts
packages/turf-random/index.d.ts
packages/turf-sample/index.d.ts
packages/turf-simplify/index.d.ts
packages/turf-square-grid/index.d.ts
packages/turf-square/index.d.ts
packages/turf-tag/index.d.ts
packages/turf-tesselate/index.d.ts
packages/turf-tin/index.d.ts
packages/turf-triangle-grid/index.d.ts
packages/turf-union/index.d.ts
packages/turf-within/index.d.ts
Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Type Declarations - TypeScript
Built-in Type Definitions. TypeScript includes declaration files for all of the standardized built-in APIs available in JavaScript runtimes.
Read more >
Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >
Documentation - Introduction - TypeScript
The Declaration Files section is designed to teach you how to write a high-quality TypeScript Declaration File. We need to assume basic familiarity...
Read more >
The repository for high quality TypeScript type definitions.
The repository for high quality TypeScript type definitions. - GitHub - DefinitelyTyped/DefinitelyTyped: The repository for high quality TypeScript type ...
Read more >
TypeScript Definitions | Developer's Guide - GrapeCity
Hence, all the DataViewsJS packages on npm include TypeScript definitions. These TypeScript declaration (d.ts) files provide the type checking and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found