alexbol99 / flatten-js

Javascript library for 2d geometry
MIT License
546 stars 56 forks source link

can't create segment with optional second point omitted #84

Open herobank110 opened 3 years ago

herobank110 commented 3 years ago

One of the overloads of the segment constructor allegedly is: (ps?: Point | undefined, pe?: Point | undefined) => Segment However when omitting the 2nd argument it fails.

Code

import Geom from '@flatten-js/core';
const { point, segment } = Geom;
segment(point(200, 200))

This code compiles correctly in Typescript.

Output

Uncaught ReferenceError: Illegal Parameters
    at Function.get ILLEGAL_PARAMETERS [as ILLEGAL_PARAMETERS] (index.js:8730)
    at new Segment (index.js:13059)
    at segment (index.js:13369)
    at Object.3syrK.jquery (index.js:453)
    at newRequire (index.js:71)
    at index.js:120
    at index.js:143

Expected segment(point(200, 200)) should run with throwing error and be equivalent to segment(point(200, 200), point())

alexbol99 commented 3 years ago

Option supported in v1.2.23