Open justin-hackin opened 2 years ago
I noticed that you can work around this by const-destructuring the imports like this: https://codesandbox.io/s/infallible-solomon-tyj8p?file=/src/index.ts . Perhaps this warrants a notice in the readme
This is how I fix it with re-exports:
flatten.ts
// This file exists to fix destructured imports in Flatten
// https://github.com/alexbol99/flatten-js/issues/98
import Flatten from '@flatten-js/core'
const {
Box,
Point,
Ray,
Vector,
Segment,
point,
circle,
// @ts-ignore
box,
segment,
} = Flatten
export type FlattenBox = Flatten.Box
export type FlattenPoint = Flatten.Point
export type FlattenRay = Flatten.Ray
export type FlattenVector = Flatten.Vector
export type FlattenSegment = Flatten.Segment
export type FlattenCircle = Flatten.Circle
// Missing in their typedefs
type box = (xmin?: number, ymin?: number, xmax?: number, ymax?: number) => FlattenBox
export { Box, Point, Ray, Vector, Segment, point, circle, box, segment }
(add all the shapes you need)
Then I can do :
import { box, FlattenBox } from './flatten'
I'm not sure why the type definitions aren't working when destructuring the default import but I always get TS2614 error when importing
Here's a reproduction: https://codesandbox.io/s/dark-sound-r7148?file=/src/index.ts
It's been like this since I started using the package several years ago.