Skip to content

Commit 4c2b609

Browse files
ZTongciclaude
andcommitted
fix(build): work around @turf/unkink-polygon missing types exports condition
The package's "exports" field has no "types" condition, so TypeScript with moduleResolution:bundler cannot link the ESM import to index.d.ts. Switch to require() which bypasses exports-field resolution and add an explicit return-type cast so downstream uses are still fully typed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 43b70fb commit 4c2b609

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/engines/Cesium/utils/polygon.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
// ref: https://github.com/takram-design-engineering/plateau-view/blob/main/libs/cesium-helpers/src/convertPolygonToHierarchyArray.ts
22

33
import { Cartesian3, type PolygonHierarchy } from "@cesium/engine";
4-
import unkinkPolygon from "@turf/unkink-polygon";
5-
import type { LineString, MultiPolygon, Polygon, Position } from "geojson";
4+
import type { Feature, LineString, MultiPolygon, Polygon, Position } from "geojson";
5+
6+
// @turf/unkink-polygon's package.json "exports" field is missing a "types" condition,
7+
// so TypeScript cannot resolve its types via the default ESM import with
8+
// moduleResolution: bundler. require() bypasses exports-field resolution.
9+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-explicit-any
10+
const unkinkPolygon = ((require("@turf/unkink-polygon") as any).default ?? require("@turf/unkink-polygon")) as (
11+
input: Polygon | MultiPolygon,
12+
) => { features: Array<Feature<Polygon>> };
613

714
export function isNotNullish<T>(value: T | null | undefined): value is T {
815
return value != null;

0 commit comments

Comments
 (0)