Created
April 30, 2018 17:19
-
-
Save milesj/fa5a291874bf5c15c1b0e0e3fa894024 to your computer and use it in GitHub Desktop.
TS function interface inferrence
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
import React from 'react'; | |
interface ComponentProps {} | |
// Inferred, don't need to do anything (preferred) | |
function Component(props: ComponentProps) {} | |
// Using "this" special argument, but this does not support static properties or methods | |
function Component(this: React.SFC<ComponentProps>, props: ComponentProps) {} | |
// Using a special "static" argument (or something similar) | |
function Component(static: React.SFC<ComponentProps>, props: ComponentProps) {} | |
// Explicitly casting using "as" | |
function Component(props: ComponentProps) {} as React.SFC<ComponentProps>; | |
export default Component; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment