Last active
September 6, 2015 18:36
-
-
Save alihammad-gist/11e528adf2ce2837ef37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///<reference path="tree.d.ts"/> | |
///<reference path="../../typings/tsd.d.ts"/> | |
type ReactElement = React.ReactElement<any> | |
type TreeItem = Tree.Item | |
/* | |
Same function signature as Tree.ItemReactElementFactory | |
(which is defined in tree.d.ts - gist is below) | |
*/ | |
interface ItemReactElementFactory { | |
(data:TreeItem): ReactElement; | |
} | |
// Local function interface works | |
var factory1:ItemReactElementFactory = function (data:TreeItem) :ReactElement { | |
return React.DOM.b({}, "hello"); | |
}; | |
// Function interface from tree.d.ts gives error even though both | |
// ItemReactElementFactory and Tree.ItemReactElementFactory have same signature | |
var factory2:Tree.ItemReactElementFactory = function (data:TreeItem) :ReactElement { | |
return React.DOM.b({}, "hello"); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///<reference path="../../typings/tsd.d.ts"/> | |
declare module Tree { | |
import React = __React; | |
type ItemValue = string | number; | |
interface Item { | |
[key: string]: ItemValue | Data; // scalar ItemValue or Nested Data | |
} | |
type Data = Item[]; | |
// This one doesn't work | |
interface ItemReactElementFactory { | |
(data:Item): React.ReactElement<any>; | |
} | |
interface OnParentChange { | |
(src_key:ItemValue, old_parent_key:ItemValue, new_parent_key:ItemValue): void | |
} | |
interface OnOrderChange { | |
(src_key:ItemValue, old_idx:number, new_idx:number): void | |
} | |
interface TreeProps { | |
data: Data; | |
factory: ItemReactElementFactory; | |
children_hash: string; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment