Created
February 22, 2017 23:45
-
-
Save FremyCompany/8dffc56b1b4265b915c5aae5e881bfd1 to your computer and use it in GitHub Desktop.
Small helper to get autocompletion when authoring Mitrhil components in Typescript
This file contains 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
function Component<T>(view: (attributes: T, children: Array<any>) => Mithril.VirtualElement): () => Mithril.Component<Mithril.ControllerWithAttributes<T>> & { attributes?: T} { | |
return () => ({ view(n) { return view(n.attributes, n.children); } } as any); | |
} | |
var Abc = Component<{ input:string, value:string }>(a => | |
<div>{a.input}</div> | |
); | |
var t = <Abc input="true" value="true" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment