-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add typings for 'dojox/gfx' #43
Conversation
Exported object is a singleton instance
r: number; | ||
} | ||
|
||
// TODO: maybe complete this? (probably not important) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update this comment to list what is missing and why we're leaving it off (e.g. renderers are mostly an internal construct). That way if somebody does need this they at least know why it's incomplete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
y: number; | ||
} | ||
|
||
interface RadialFill { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this extend SimpleShape? I ask because RadialGradient does and both have optional type
params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might in fact be useless code. It's hard to tell. It looks like this typedef is only applicable to dojox/gfx/gradutils.getColor
, which AFAICT isn't even used anywhere in dojox.gfx
. SimpleShape
is a construct of my inventing, since there are also dojox.gfx.shape.Shape
shapes. I think we can leave this as-is until/if someone finds that it would work better if it is changed.
} | ||
|
||
interface MoverConstructor extends dojo._base.DeclareConstructor<Mover> { | ||
new(shape: dojox.gfx.shape.Shape, event: MouseEvent, host: Moveable): Mover; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this file need a reference to shape or will TypeScript attempt to search for local .d.ts files?
/// <reference path="shape.d.ts" />
So if somebody used only this definition I believe they would get a missing definition error, but I'm not sure. Worth following up on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience adding reference paths to .d.ts
files causes namespace resolution to fail.
moveTo(x: number, y: number): this; | ||
qCurveTo(x1: number, y1: number, x: number, y: number): this; | ||
setAbsoluteMode(mode: boolean | string): void; // TODO: enum | ||
// setShape(shape: string | dojox.gfx.path.Path): this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It exists here because this is where I wish we could define it, but TS doesn't work like that. It also exists elsewhere, where we have to define it if we don't want to get errors.
const Path: dojox.gfx.path.PathConstructor; | ||
type TextPath = dojox.gfx.path.TextPath; | ||
const TextPath: dojox.gfx.path.TextPathConstructor; | ||
/* tslint:enable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need an export statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - if you assign to export
, then whatever you assign to export
is all that gets exported - all the other statements have no effect.
y: number; | ||
} | ||
|
||
interface Container { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be ok to have the children
property listed too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks!
createImage(options: dojox.gfx.SimpleImage): Image; | ||
createLine(options: dojox.gfx.SimpleLine): Line; | ||
createObject(constructor: ShapeConstructor, simpleShape?: SimpleShape): Shape; | ||
createPath(options: dojox.gfx.SimplePath): dojox.gfx.path.Path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createPath()
also accepts string
like setShape
setShape(shape: dojox.gfx.SimpleShape): this;
// for Path
setShape(shape: string | dojox.gfx.path.Path): this;
// for Polyline
setShape(points: Point[] | { points: Point[] }, closed?: boolean): this;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
||
interface Stroke extends SimpleShape { | ||
cap?: string; // TODO: enum | ||
color?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color
can be number[]
, string
, dojo/_base/Color
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
merged in df21978 |
This PR adds typings to make
dojox/gfx
usable with TypeScript.It omits typings for all renderers, since those modules are not typically loaded directly. The API they implement is typed in the
gfx.d.ts
andgfx/shapes.d.ts
files.Also omitted:
_gfxBidiSupport
: this module just modifies the basegfx
moduleattach
: this module is emptyrenderer
: this module is an AMD loader plugin for loading the default rendererTypings for two
dojox
dependencies outside ofdojox/gfx
are also included:dojox/html/metrics
dojox/xml/DomParser