Hi! It seems that typings for distance do not work out-of-the-box.
STR:
npm install --save @turfimport distance from '@turf/distance';Compiler says:
Type error: Could not find a declaration file for module '@turf/distance'. 'src/node_modules/@turf/distance/index.js' implicitly has an 'any' type.
Try `npm install @types/turf__distance` if it exists or add a new declaration (.d.ts) file containing `declare module '@turf/distance';` TS7016
Though if I suppress it, no errors occur while runtime.
When I look into /distance module, there is no .ts files there:

Tried the following steps to fix:
npm install @types/turf__distance - 404 Not Found (as turf contains types on its own, not in types reponpm install @types/turf - old version of typingsnpm install @turf/turf - better, I can use typings as well as distance itself, but only in way when I import the entire turf lib. So that bundle size increased by 300kb, doesn't fit.dts-gen @turf/distance - no .ts files there to create the .d.ts fileThe question is: how can I use the single @turf/distance module along with TypeScript typings?
@DenisCarriere please clarify
Hi @goodwin64
Typings aren't my strength and Denis isn't involved in the project at the moment.
Can you perhaps try one of the version 5 packages available on npm? Some of the version 6 stuff was a bit experimental and wasn't tagged as an alpha unfortunantly, but the v5 stuff should be fairly stable.
Cheers
Rowan
I think the issue is just an incorrectly released version - other @turf/* packages written in ts have index.d.ts along with index.js, but @turf/distance does not.
Maybe somebody from the @turf team could re-release this package only?

It is not a packaging issue, the files was removed with this commit
https://github.com/Turfjs/turf/commit/5fab0fe342b264d8b20a515dc55539191b4fdabe#diff-6d071eff6c43993c40d93a8b2b275048
It is unclear why.

The index.d.ts was removed because the code itself is written in typescript now (index.ts), which should be translated into index.js + index.d.ts during packaging process.
Also happening for at least these packages:
@turf/[email protected]
@turf/[email protected]
@turf/[email protected]
@rowanwins I'm sorry to disturb but are there any updates on this topic? Whom of the contributors could you suggest to clarify?
Hi @goodwin64
Have you tried one of the v5 releases? Packaging a new release for the v6 series is very complicated and unlikely to happen and there shouldn't be any performance difference rolling back to v5.
None of the current contributors have much experience with typescript sorry
Any luck with these? Ended up importing the whole package myself even though I only need the distance.
Using the latest v5 release worked for me 馃憤
any updates for ^6.0.0?
my workaround with @turf/[email protected].
// turf-distance.d.ts
declare module "@turf/distance" {
import { Units, Coord } from "@turf/helpers";
function distance(from: Coord, to: Coord, options: { units?: Units }): number;
export default distance;
}
Try install @types/turf :)
Most helpful comment
my workaround with
@turf/[email protected].