replit / kaboom

💥 JavaScript game library
https://kaboomjs.com
MIT License
2.67k stars 228 forks source link

Inconsistent TS type def for Vec2 #759

Closed namiwang closed 1 year ago

namiwang commented 1 year ago
import { Vec2 } from "kaboom"
...
new Vec2(point.x, point.y)

TS thinks this code is fine, yet the transpiled code is not working due to errors like

[react-scripts] export 'Vec2' (imported as 'Vec2') was not found in 'kaboom' (possible exports: default)
magical-heyrovsky commented 1 year ago

I recommend using https://kaboomjs.com/#vec2 instead.

slmjkdbtl commented 1 year ago

Yea it's a bit confusing

import { Vec2 } from "kaboom"

Should only import the type, the actual class is under KaboomCtx

const k = kaboom()

new k.Vec2(10, 20)