fable-compiler / ts2fable

Parser of Typescript declaration files
http://fable.io/ts2fable/
Apache License 2.0
224 stars 34 forks source link

Problem with modules starting with @ #269

Open citymeterio opened 5 years ago

citymeterio commented 5 years ago

I'm trying to use Fable with turfjs but the problem is that the package start with @ (@turf/turf) hence the ts2fable generates invalid F# code like

// ts2fable 0.6.1
module rec ModuleName
open System
open Fable.Core
open Fable.Import.JS

let [<Import("*","module")>] ``@turf/along``: @turf_along.IExports = jsNative
// many more similar lines 

There exists old package with definition file for turf without the @'s and F# produces no errors but fable complains following while I want to call turf.point( cords) ERROR in ./src/App.fs Module not found: Error: Can't resolve 'module' in ...

Do I have to somehow instruct fable that it should point to specific node module (turfjs here)? I'm using the minimal fable template

MangelMaxime commented 5 years ago

You need to replace module probably by @turf/along in let [<Import("*","module")>]

citymeterio commented 5 years ago

Thanks @MangelMaxime for suggestion, I went with [Import("*","@turf/turf") and Fable is satisfied :)

But...

turf.point expects Fable.Import.JS.Array which I 'm providing like 👍
let cords = !![|3.;3.|]; let tp = turf.point(cords, None)

and my browser is not satisifed saying prelude.fs:5 Unable to process a message: Error: coordinates must be an Array

understanding cords as Float64Array(2) 0: 3 1: 3 buffer: (...) byteLength: (...) byteOffset: (...) length: (...) Symbol(Symbol.toStringTag): (...) __proto__: TypedArray

MangelMaxime commented 5 years ago

Can you try using ?

let cords = ResizeArray([3.;3.])

This is strange because I would expected JavaScript to consider Float64Array & co to be specialized array.

citymeterio commented 5 years ago

works but still need to satisify the binding with !! operator let cords = ResizeArray([3.;3.]) let tp = turf.point(!!cords)

MangelMaxime commented 5 years ago

Can you please share with us the generated bindings here ?

So we can look at it and see if we can do something or if you need to modify for improvement :)

PS: Can you share the generated bindings and the d.ts used as entry :)

citymeterio commented 5 years ago

here is the generated turfjs binding (it is from old definition file, not the one provided with @turf Update: I do not have access to the origin definition file on my current machine :/

// ts2fable 0.6.1

module rec MyTurf
open System
open Fable.Core
open Fable.Import.JS

let [<Import("*","@turf/turf")>] turf: Turf.TurfStatic = jsNative
let [<Import("*","module")>] TemplateUnits: obj = jsNative
let [<Import("*","module")>] TemplateType: U4<string, string, string, string> = jsNative

type [<AllowNullLiteral>] OptionsRandom =
    abstract bbox: Array<float> option with get, set
    abstract num_vertices: float option with get, set
    abstract max_radial_length: float option with get, set

type [<AllowNullLiteral>] PropReduceCallback =
    [<Emit "$0($1...)">] abstract Invoke: memo: obj option * coord: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> obj option

module Turf =

    type [<AllowNullLiteral>] TurfStatic =
        /// <summary>Merges a specified property from a FeatureCollection of points into a FeatureCollection of polygons. Given an `inProperty` on points and an `outProperty` for polygons, this finds every point that lies within each polygon, collects the `inProperty` values from those points, and adds them as an array to `outProperty` on the polygon.</summary>
        /// <param name="polygons">polygons with values on which to aggregate</param>
        /// <param name="points">points to be aggregated</param>
        /// <param name="inProperty">property to be nested from</param>
        /// <param name="outProperty">property to be nested into</param>
        abstract collect: polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon> * points: GeoJSON.FeatureCollection<GeoJSON.Point> * inProperty: string * outProperty: string -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        /// <summary>Takes a line and returns a point at a specified distance along the line.</summary>
        /// <param name="line">Input line</param>
        /// <param name="distance">Distance along the line</param>
        /// <param name="units">'miles', 'kilometers', 'radians' or 'degrees'</param>
        abstract along: line: GeoJSON.Feature<GeoJSON.LineString> * distance: float * ?units: obj -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Takes one or more features and returns their area in square meters.</summary>
        /// <param name="input">Input features</param>
        abstract area: input: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> float
        /// Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
        abstract bbox: bbox: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> Array<float>
        /// <summary>Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.</summary>
        /// <param name="center">center point</param>
        /// <param name="radius">radius of the circle</param>
        /// <param name="steps">number of steps</param>
        /// <param name="units">miles, kilometers, degrees, or radians</param>
        abstract circle: center: GeoJSON.Feature<GeoJSON.Point> * radius: float * ?steps: float * ?units: obj -> GeoJSON.Feature<GeoJSON.Polygon>
        /// <summary>Enforce expectations about types of GeoJSON objects for Turf.</summary>
        /// <param name="value">any GeoJSON object</param>
        /// <param name="type">expected GeoJSON type</param>
        /// <param name="name">name of calling function</param>
        abstract geojsonType: value: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> * ``type``: string * name: string -> unit
        /// <summary>Reduce properties in any GeoJSON object into a single value, similar to how Array.reduce works. However, in this case we lazily run the reduction, so an array of all properties is unnecessary.</summary>
        /// <param name="layer">any GeoJSON object</param>
        /// <param name="callback">a method that takes (memo, coord) and returns a new memo</param>
        /// <param name="memo">the starting value of memo: can be any type.</param>
        abstract propReduce: layer: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> * callback: PropReduceCallback * memo: obj option -> obj option
        /// <summary>Get all coordinates from any GeoJSON object, returning an array of coordinate arrays.</summary>
        /// <param name="layer">any GeoJSON object</param>
        abstract coordAll: layer: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> Array<Array<float>>
        /// Tesselates a {@link Feature<Polygon>} into a {@link FeatureCollection<Polygon>} of triangles using [earcut](https://github.com/mapbox/earcut).
        abstract tesselate: poly: GeoJSON.Feature<GeoJSON.Polygon> -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        /// <summary>Takes a bbox and returns an equivalent polygon.</summary>
        /// <param name="bbox">An Array of bounding box coordinates in the form: [xLow, yLow, xHigh, yHigh]</param>
        abstract bboxPolygon: bbox: Array<float> -> GeoJSON.Feature<GeoJSON.Polygon>
        /// <summary>Takes two points and finds the geographic bearing between them.</summary>
        /// <param name="start">Starting Point</param>
        /// <param name="end">Ending point</param>
        abstract bearing: start: GeoJSON.Feature<GeoJSON.Point> * ``end``: GeoJSON.Feature<GeoJSON.Point> -> float
        /// <summary>Takes a FeatureCollection and returns the absolute center point of all features.</summary>
        /// <param name="features">Input features</param>
        abstract center: features: GeoJSON.FeatureCollection<obj option> -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Takes one or more features and calculates the centroid using the arithmetic mean of all vertices.
        /// This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.</summary>
        /// <param name="features">Input features</param>
        abstract centroid: features: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers and bearing in degrees.
        /// This uses the Haversine formula to account for global curvature.</summary>
        /// <param name="start">Starting point</param>
        /// <param name="distance">Distance from the starting point</param>
        /// <param name="bearing">Ranging from -180 and 180</param>
        /// <param name="units">'miles', 'kilometers', 'radians', or 'degrees'</param>
        abstract destination: start: GeoJSON.Feature<GeoJSON.Point> * distance: float * bearing: float * ?units: obj -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Calculates the distance between two points in degress, radians, miles, or kilometers.
        /// This uses the Haversine formula to account for global curvature.</summary>
        /// <param name="from">Origin point</param>
        /// <param name="to">Destination point</param>
        /// <param name="units">'miles', 'kilometers', 'radians', or 'degrees'</param>
        abstract distance: from: GeoJSON.Feature<GeoJSON.Point> * ``to``: GeoJSON.Feature<GeoJSON.Point> * ?units: obj -> float
        /// <summary>Takes any number of features and returns a rectangular Polygon that encompasses all vertices.</summary>
        /// <param name="fc">Input features</param>
        abstract envelope: fc: GeoJSON.FeatureCollection<obj option> -> GeoJSON.Feature<GeoJSON.Polygon>
        /// <summary>Takes a line and measures its length in the specified units.</summary>
        /// <param name="line">Line to measure</param>
        /// <param name="units">'miles', 'kilometers', 'radians', or 'degrees'</param>
        abstract lineDistance: line: GeoJSON.Feature<GeoJSON.LineString> * ?units: obj -> float
        /// <summary>Takes two points and returns a point midway between them.</summary>
        /// <param name="pt1">First point</param>
        /// <param name="pt2">Second point</param>
        abstract midpoint: pt1: GeoJSON.Feature<GeoJSON.Point> * pt2: GeoJSON.Feature<GeoJSON.Point> -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Takes a feature and returns a Point guaranteed to be on the surface of the feature. Given a Polygon, the point will be in the area of the polygon.
        /// Given a LineString, the point will be along the string. Given a Point, the point will the same as the input.</summary>
        /// <param name="input">Any feature or set of features</param>
        abstract pointOnSurface: input: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> GeoJSON.Feature<obj option>
        /// <summary>Takes a bounding box and calculates the minimum square bounding box that would contain the input.</summary>
        /// <param name="bbox">A bounding box</param>
        abstract square: bbox: Array<float> -> Array<float>
        /// <summary>Takes a line and returns a curved version by applying a Bezier spline algorithm.
        /// The bezier spline implementation is by Leszek Rybicki.</summary>
        /// <param name="line">Input LineString</param>
        /// <param name="resolution">Time in milliseconds between points</param>
        /// <param name="sharpness">A measure of how curvy the path should be between splines</param>
        abstract bezier: line: GeoJSON.Feature<GeoJSON.LineString> * ?resolution: float * ?sharpness: float -> GeoJSON.Feature<GeoJSON.LineString>
        /// <summary>Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.</summary>
        /// <param name="feature">Input to be buffered</param>
        /// <param name="distance">Distance to draw the buffer</param>
        /// <param name="units">'miles', 'kilometers', 'radians', or 'degrees'</param>
        abstract buffer: feature: GeoJSON.Feature<GeoJSON.Polygon> * distance: float * ?units: obj -> GeoJSON.Feature<GeoJSON.Polygon>
        abstract buffer: feature: GeoJSON.Feature<GeoJSON.MultiPolygon> * distance: float * ?units: obj -> GeoJSON.Feature<GeoJSON.MultiPolygon>
        abstract buffer: feature: GeoJSON.Feature<GeoJSON.Point> * distance: float * ?units: obj -> GeoJSON.Feature<GeoJSON.Point>
        abstract buffer: feature: GeoJSON.Feature<obj option> * distance: float * ?units: obj -> GeoJSON.Feature<obj option>
        abstract buffer: feature: GeoJSON.FeatureCollection<GeoJSON.Polygon> * distance: float * ?units: obj -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        abstract buffer: feature: GeoJSON.FeatureCollection<GeoJSON.MultiPolygon> * distance: float * ?units: obj -> GeoJSON.FeatureCollection<GeoJSON.MultiPolygon>
        abstract buffer: feature: GeoJSON.FeatureCollection<GeoJSON.Point> * distance: float * ?units: obj -> GeoJSON.FeatureCollection<GeoJSON.Point>
        abstract buffer: feature: GeoJSON.FeatureCollection<obj option> * distance: float * ?units: obj -> GeoJSON.FeatureCollection<obj option>
        /// <summary>Takes a set of points and returns a concave hull polygon. Internally, this implements a Monotone chain algorithm.</summary>
        /// <param name="points">Input points</param>
        /// <param name="maxEdge">The size of an edge necessary for part of the hull to become concave (in miles)</param>
        /// <param name="units">Used for maxEdge distance (miles or kilometers)</param>
        abstract concave: points: GeoJSON.FeatureCollection<GeoJSON.Point> * maxEdge: float * ?units: obj -> GeoJSON.Feature<GeoJSON.Polygon>
        /// <summary>Takes a set of points and returns a convex hull polygon. Internally this uses the convex-hull module that implements a monotone chain hull.</summary>
        /// <param name="input">Input points</param>
        abstract convex: input: GeoJSON.FeatureCollection<GeoJSON.Point> -> GeoJSON.Feature<GeoJSON.Polygon>
        /// <summary>Finds the difference between two polygons by clipping the second polygon from the first.</summary>
        /// <param name="poly1">Input Polygon feaure</param>
        /// <param name="poly2">Polygon feature to difference from poly1</param>
        abstract difference: poly1: GeoJSON.Feature<GeoJSON.Polygon> * poly2: GeoJSON.Feature<GeoJSON.Polygon> -> GeoJSON.Feature<GeoJSON.Polygon>
        /// Takes two Features and finds their intersection.
        /// If they share a border, returns the border if they don't intersect, returns undefined.
        abstract intersect: feature1: GeoJSON.Feature<GeoJSON.Polygon> * feature2: GeoJSON.Feature<GeoJSON.Polygon> -> GeoJSON.Feature<U3<GeoJSON.Point, GeoJSON.LineString, GeoJSON.Polygon>>
        abstract intersect: feature1: GeoJSON.Feature<obj option> * feature2: GeoJSON.Feature<obj option> -> GeoJSON.Feature<obj option>
        /// <summary>Takes a LineString or Polygon and returns a simplified version.
        /// Internally uses simplify-js to perform simplification.</summary>
        /// <param name="feature">Feature to be simplified</param>
        /// <param name="tolerance">Simplification tolerance</param>
        /// <param name="highQuality">Whether or not to spend more time to create a higher-quality simplification with a different algorithm</param>
        abstract simplify: feature: U3<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>, GeoJSON.GeometryCollection> * tolerance: float * highQuality: bool -> U3<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>, GeoJSON.GeometryCollection>
        /// <summary>Takes two polygons and returns a combined polygon.
        /// If the input polygons are not contiguous, this function returns a MultiPolygon feature.;</summary>
        /// <param name="poly1">Input polygon</param>
        /// <param name="poly2">Another input polygon</param>
        abstract union: poly1: GeoJSON.Feature<GeoJSON.Polygon> * poly2: GeoJSON.Feature<GeoJSON.Polygon> -> GeoJSON.Feature<U2<GeoJSON.Polygon, GeoJSON.MultiPolygon>>
        /// <summary>Combines a FeatureCollection of Point, LineString, or Polygon features into MultiPoint, MultiLineString, or MultiPolygon features.</summary>
        /// <param name="fc">A FeatureCollection of any type</param>
        abstract combine: fc: GeoJSON.FeatureCollection<obj option> -> GeoJSON.FeatureCollection<obj option>
        /// <summary>Takes a feature or set of features and returns all positions as points.</summary>
        /// <param name="input">Input features</param>
        abstract explode: input: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> GeoJSON.FeatureCollection<GeoJSON.Point>
        /// <summary>Takes input features and flips all of their coordinates from [x, y] to [y, x].</summary>
        /// <param name="input">Input features</param>
        abstract flip: input: U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>> -> U2<GeoJSON.Feature<obj option>, GeoJSON.FeatureCollection<obj option>>
        /// <summary>Takes a polygon and returns points at all self-intersections.</summary>
        /// <param name="polygon">Input polygon</param>
        abstract kinks: polygon: GeoJSON.Feature<GeoJSON.Polygon> -> GeoJSON.FeatureCollection<GeoJSON.Point>
        /// <summary>Takes a line, a start Point, and a stop point and returns the line in between those points.</summary>
        /// <param name="point1">Starting point</param>
        /// <param name="point2">Stopping point</param>
        /// <param name="line">Line to slice</param>
        abstract lineSlice: point1: GeoJSON.Feature<GeoJSON.Point> * point2: GeoJSON.Feature<GeoJSON.Point> * line: GeoJSON.Feature<GeoJSON.LineString> -> GeoJSON.Feature<GeoJSON.LineString>
        /// <summary>Takes a Point and a LineString and calculates the closest Point on the LineString.</summary>
        /// <param name="line">Line to snap to</param>
        /// <param name="point">Point to snap from</param>
        abstract pointOnLine: line: GeoJSON.Feature<GeoJSON.LineString> * point: GeoJSON.Feature<GeoJSON.Point> -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.</summary>
        /// <param name="features">input features</param>
        abstract featureCollection: features: Array<GeoJSON.Feature<obj option>> -> GeoJSON.FeatureCollection<obj option>
        /// <summary>Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.</summary>
        /// <param name="geometry">input geometry</param>
        /// <param name="properties">properties</param>
        abstract feature: geometry: GeoJSON.Feature<obj option> * ?properties: obj option -> GeoJSON.Feature<obj option>
        /// <summary>Creates a {@link LineString} based on a coordinate array. Properties can be added optionally.</summary>
        /// <param name="coordinates">an array of Positions</param>
        /// <param name="properties">an Object of key-value pairs to add as properties</param>
        abstract lineString: coordinates: Array<Array<float>> * ?properties: obj option -> GeoJSON.Feature<GeoJSON.LineString>
        /// <summary>Creates a {@link Feature<MultiLineString>} based on a coordinate array. Properties can be added optionally.</summary>
        /// <param name="coordinates">an array of LineStrings</param>
        /// <param name="properties">an Object of key-value pairs to add as properties</param>
        abstract multiLineString: coordinates: Array<Array<Array<float>>> * ?properties: obj option -> GeoJSON.Feature<GeoJSON.MultiLineString>
        /// <summary>Takes coordinates and properties (optional) and returns a new {@link Point} feature.</summary>
        /// <param name="coordinates">longitude, latitude position (each in decimal degrees)</param>
        /// <param name="properties">an Object that is used as the {</param>
        abstract point: coordinates: Array<float> * ?properties: obj option -> GeoJSON.Feature<GeoJSON.Point>
        /// <summary>Creates a {@link Feature<MultiPoint>} based on a coordinate array. Properties can be added optionally.</summary>
        /// <param name="coordinates">an array of Positions</param>
        /// <param name="properties">an Object of key-value pairs to add as properties</param>
        abstract multiPoint: coordinates: Array<Array<float>> * ?properties: obj option -> GeoJSON.Feature<GeoJSON.MultiPoint>
        /// <summary>Takes an array of LinearRings and optionally an {@link Object} with properties and returns a {@link Polygon} feature.</summary>
        /// <param name="coordinates">an array of LinearRings</param>
        /// <param name="properties">a properties object</param>
        abstract polygon: coordinates: Array<Array<Array<float>>> * ?properties: obj option -> GeoJSON.Feature<GeoJSON.Polygon>
        /// <summary>Creates a {@link Feature<MultiPolygon>} based on a coordinate array. Properties can be added optionally.</summary>
        /// <param name="coordinates">an array of Polygons</param>
        /// <param name="properties">an Object of key-value pairs to add as properties</param>
        abstract multiPolygon: coordinates: Array<Array<Array<Array<float>>>> * ?properties: obj option -> GeoJSON.Feature<GeoJSON.MultiPolygon>
        /// <summary>Creates a {@link Feature<GeometryCollection>} based on acoordinate array. Properties can be added optionally.</summary>
        /// <param name="geometries">an array of GeoJSON Geometries</param>
        /// <param name="properties">an Object of key-value pairs to add as properties</param>
        abstract geometryCollection: geometries: Array<GeoJSON.GeometryObject> * ?properties: obj option -> GeoJSON.GeometryCollection
        /// <summary>Generates random {@link GeoJSON} data, including {@link Point|Points} and {@link Polygon|Polygons}, for testing and experimentation.</summary>
        /// <param name="count">how many geometries should be generated.</param>
        /// <param name="options">the total number of decimal
        /// degrees longitude or latitude that a polygon can extent outwards to
        /// from its center.</param>
        [<Emit "$0.random('point',$1,$2)">] abstract random_point: ?count: float * ?options: OptionsRandom -> GeoJSON.FeatureCollection<GeoJSON.Point>
        [<Emit "$0.random('points',$1,$2)">] abstract random_points: ?count: float * ?options: OptionsRandom -> GeoJSON.FeatureCollection<GeoJSON.Point>
        [<Emit "$0.random('polygon',$1,$2)">] abstract random_polygon: ?count: float * ?options: OptionsRandom -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        [<Emit "$0.random('polygons',$1,$2)">] abstract random_polygons: ?count: float * ?options: OptionsRandom -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        abstract random: ?``type``: obj * ?count: float * ?options: OptionsRandom -> GeoJSON.FeatureCollection<obj option>
        /// <summary>Takes a {@link FeatureCollection} and returns a FeatureCollection with given number of {@link Feature|features} at random.</summary>
        /// <param name="featurecollection">set of input features</param>
        /// <param name="num">number of features to select</param>
        abstract sample: featurecollection: GeoJSON.FeatureCollection<obj option> * num: float -> GeoJSON.FeatureCollection<obj option>
        /// <summary>Takes a bounding box and a cell size in degrees and returns a {@link FeatureCollection} of flat-topped hexagons ({@link Polygon} features) aligned in an "odd-q" vertical grid as described in [Hexagonal Grids](http://www.redblobgames.com/grids/hexagons/).</summary>
        /// <param name="bbox">bounding box in [minX, minY, maxX, maxY] order</param>
        /// <param name="cellSize">dimension of cell in specified units</param>
        /// <param name="units">used in calculating cellSize ('miles' or 'kilometers')</param>
        /// <param name="triangles">whether to return as triangles instead of hexagons</param>
        abstract hexGrid: bbox: Array<float> * cellSize: float * ?units: obj * ?triangles: bool -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        /// <summary>Takes a bounding box and a cell depth and returns a set of {@link Point|points} in a grid.</summary>
        /// <param name="bbox">extent in [minX, minY, maxX, maxY] order</param>
        /// <param name="cellSize">the distance across each cell</param>
        /// <param name="units">used in calculating cellSize, can be degrees, radians, miles, or kilometers</param>
        abstract pointGrid: bbox: Array<float> * cellSize: float * ?units: obj -> GeoJSON.FeatureCollection<GeoJSON.Point>
        /// <summary>Takes a bounding box and a cell depth and returns a set of square {@link Polygon|polygons} in a grid.</summary>
        /// <param name="bbox">extent in [minX, minY, maxX, maxY] order</param>
        /// <param name="cellSize">width of each cell</param>
        /// <param name="units">used in calculating cellSize, can be degrees, radians, miles, or kilometers</param>
        abstract squareGrid: bbox: Array<float> * cellSize: float * ?units: obj -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        /// <summary>Takes a bounding box and a cell depth and returns a set of triangular {@link Polygon|polygons} in a grid.</summary>
        /// <param name="bbox">extent in [minX, minY, maxX, maxY] order</param>
        /// <param name="cellSize">dimension of each cell</param>
        /// <param name="units">used in calculating cellSize, can be degrees, radians, miles, or kilometers</param>
        abstract triangleGrid: bbox: Array<float> * cellSize: float * ?units: obj -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        /// <summary>Takes points with z-values and an array of value breaks and generates isolines.</summary>
        /// <param name="points">Input points</param>
        /// <param name="z">The property name in points from which z-values will be pulled</param>
        /// <param name="resolution">Resolution of the underlying grid</param>
        /// <param name="breaks">Where to draw contours</param>
        abstract isolines: points: GeoJSON.FeatureCollection<GeoJSON.Point> * z: string * resolution: float * breaks: Array<float> -> GeoJSON.FeatureCollection<GeoJSON.LineString>
        /// <summary>Takes a triangular plane as a Polygon and a Point within that triangle and returns the z-value at that point.
        /// The Polygon needs to have properties a, b, and c that define the values at its three corners.</summary>
        /// <param name="triangle">A Polygon feature with three vertices</param>
        abstract planepoint: interpolatedpoint: GeoJSON.Feature<GeoJSON.Point> * triangle: GeoJSON.Feature<GeoJSON.Polygon> -> float
        /// <summary>Takes a set of points and the name of a z-value property and creates a Triangulated Irregular Network, or a TIN for short, returned as a collection of Polygons.
        /// These are often used for developing elevation contour maps or stepped heat visualizations.
        /// This triangulates the points, as well as adds properties called a, b, and c representing the value of the given propertyName at each of the points that represent the corners of the triangle.</summary>
        /// <param name="points">Input points</param>
        /// <param name="propertyName">Name of the property from which to pull z values This is optional: if not given, then there will be no extra data added to the derived triangles.</param>
        abstract tin: points: GeoJSON.FeatureCollection<GeoJSON.Point> * ?propertyName: string -> GeoJSON.FeatureCollection<GeoJSON.Polygon>
        /// <summary>Takes a {<Point>} and a {<Polygon>} or {<MultiPolygon>} and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.</summary>
        /// <param name="point">input point</param>
        /// <param name="polygon">input polygon or multipolygon</param>
        abstract inside: point: GeoJSON.Feature<GeoJSON.Point> * polygon: GeoJSON.Feature<GeoJSON.Polygon> -> bool
        /// <summary>Takes a {FeatureCollection<Point>} and a {FeatureCollection<Polygon>} and performs a spatial join.</summary>
        /// <param name="points">input points</param>
        /// <param name="polygons">input polygons</param>
        /// <param name="field">property in `polygons` to add to joined {<Point>} features</param>
        /// <param name="outField">property in `points` in which to store joined property from `polygons`</param>
        abstract tag: points: GeoJSON.FeatureCollection<GeoJSON.Point> * polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon> * field: string * outField: string -> GeoJSON.FeatureCollection<GeoJSON.Point>
        /// <summary>Takes a set of points and a set of polygons and returns the points that fall within the polygons.</summary>
        /// <param name="points">Input points</param>
        /// <param name="polygons">Input polygons</param>
        abstract within: points: GeoJSON.FeatureCollection<GeoJSON.Point> * polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon> -> GeoJSON.FeatureCollection<GeoJSON.Point>
        /// <summary>Takes a reference point and a set of points and returns the point from the set closest to the reference.</summary>
        /// <param name="point">The reference point</param>
        /// <param name="against">Input point set</param>
        abstract nearest: point: GeoJSON.Feature<GeoJSON.Point> * against: GeoJSON.FeatureCollection<GeoJSON.Point> -> GeoJSON.Feature<GeoJSON.Point>
citymeterio commented 5 years ago

It is working but I still have some obstacles not knowing it is the lack of my experience with those tools or the binding inaccuracy problem. Following is compiling only with the casting as turf.featureCollection returns 'obj option' instead of 'Point'

//bikes is my array of lat/lon records
let data = bikes |> Array.map (fun bike -> turf.point(!!ResizeArray([bike.lat; bike.lon] )))
let cords = ResizeArray([51.12;17.01])
let myPoint = turf.point(!!cords)

let bikesCollection = turf.featureCollection(!!data) :?> FeatureCollection<Point>
let nearest = turf.nearest(myPoint, bikesCollection)