Closed BistroStu closed 2 years ago
In addition, instead of
export type Coord = number | string
the Coord type could be further constrained using a template literal:
export type Coord = number | `${number}%`
Thanks for the issue and patch @BistroStu !
Also, i've never seen ${number}%
used in lieu of string
before - appreciate the new found syntax. :-)
${number}%
provides an error while TS compilation. "TS2693: Number only refers to a type, but is being used as a value here."
I'm using TS 3.9.7
Version
Please specify what version of the library you are using: [ 3.10 ] Please specify what version(s) of PowerPoint you are targeting: [ any ]
Expected / Desired Behavior / Question
When the sizing properties of ImageProps are specified as a percentage of the slide dimensions, the code should compile in Typescript, because it works at runtime:
sizing w, h, x, y should be typed
Coord
, the same asPositionProps
and others.Observed Behavior
Typescript reports error "Type 'string' is not assignable to type 'number'." because those four properties are all typed
number
.Steps to Reproduce
Type the above into VS Code.
I will submit a pull request.