d3 and typescript

139 views
Skip to first unread message

Ulrich Sinn

unread,
Apr 17, 2015, 2:35:18 PM4/17/15
to d3...@googlegroups.com
webstorm flags errors inside of my typescript file. It compiles fine. Should the correct type be found in "d3.d.ts"?
Do I have to cast 'this' first to <EventTarget>? I'm kind of new to typescript, so I apologize for asking the wrong question.

declare module D3 {
export interface Selectors {
/**
* Select an element from the current document
*/
select: {
/**
* Returns the empty selection
*/
(): Selection;
/**
* Selects the first element that matches the specified selector string
*
* @param selector Selection String to match
*/
(selector: string): Selection;
/**
* Selects the specified node
*
* @param element Node element to select
*/
(element: EventTarget): Selection;
};





Ulrich Sinn

unread,
Apr 17, 2015, 3:11:56 PM4/17/15
to d3...@googlegroups.com
Answering my own question, yes it does remove the compiler error.

.on("click", function (d, i) {
d3.selectAll(".plusVertical").classed("hidden", false);
var evt = d3.event;
var evtTarget:EventTarget = <EventTarget>this;
var sel = d3.select(evtTarget);
sel.selectAll(".plusVertical").classed("hidden", true);
owner.dispatchPlusClick(d, i, evt)
});

Reply all
Reply to author
Forward
0 new messages