jemgold / figma-js

Little wrapper (+ types) for the Figma API
https://jongold.github.io/figma-js/
MIT License
491 stars 47 forks source link

Duplicate types for Rectangle #6

Closed dvdsgl closed 6 years ago

dvdsgl commented 6 years ago

The Rectangle node type and the Rectangle primitive have the same name.

jemgold commented 6 years ago

@dvdsgl any suggestions on this one too?

I wonder if we could namespace types - https://www.figma.com/developers/docs breaks them into Node Properties and File Format Types

dvdsgl commented 6 years ago

Well, you could create a types.ts module with base types, and nodes.ts with nodes, etc., then import types with a prefix or an alias.

I renamed the primitive struct to Rect:

/** A rectangle that expresses a bounding box in absolute coordinates */
export interface Rect {
  /** X coordinate of top left corner of the rectangle */
  x: number;
  /** Y coordinate of top left corner of the rectangle */
  y: number;
  /** Width of the rectangle */
  width: number;
  /** Height of the rectangle */
  height: number;
}