jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.29k stars 454 forks source link

[Bug] Two options doesn't have `ratio` typed in TypeScript #681

Closed cdaein closed 1 year ago

cdaein commented 1 year ago

When I use ratio option, I can see it affects pixel ratio of the canvas, but I get a type error

const two = new Two({
  type: Two.Types.canvas,
  width: 500,
  height: 500,
  ratio: 1, // no type
});

Error:

Argument of type '{ type: string; width: number; height: number; ratio: number; }' is not assignable to parameter of type '{ fullscreen?: boolean | undefined; fitted?: boolean | undefined; autostart?: boolean | undefined; width?: number | undefined; height?: number | undefined; type?: string | undefined; domElement?: HTMLElement | undefined; overdraw?: boolean | undefined; smoothing?: boolean | undefined; }'.
  Object literal may only specify known properties, and 'ratio' does not exist in type '{ fullscreen?: boolean | undefined; fitted?: boolean | undefined; autostart?: boolean | undefined; width?: number | undefined; height?: number | undefined; type?: string | undefined; domElement?: HTMLElement | undefined; overdraw?: boolean | undefined; smoothing?: boolean | undefined; }'.ts(2345)
jonobr1 commented 1 year ago

Thanks for posting. This patch fixes that: https://github.com/jonobr1/two.js/pull/682

jonobr1 commented 1 year ago

I'll be updating NPM in the coming days. Until then you can use the github repository directly through npm.