Skip to content

@turf/lineOffset return type does not keep the geojson type anymore #3006

@tahini

Description

@tahini

#2974 converted the line-offset package to typescript, but the generated return type of the function is not the same as previously and causes compilation errors in projects using it.

The function signature was previously:

declare function lineOffset<T extends LineString | MultiLineString>(
  line: Feature<T> | T,
  distance: number,
  options?: {
    units?: Units;
  }
): Feature<T>;

Which preserved the LineString or MultiLineString type of the feature in parameter.

But now it is:

declare function lineOffset<T extends LineString | MultiLineString>(geojson: Feature<T> | T, distance: number, options?: {
    units?: Units;
}): Feature<LineString, {
    [name: string]: any;
} | null> | Feature<MultiLineString, {
    [name: string]: any;
} | null>;

So when passing a LineString, the return value is not necessarily a LineString anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions