Created
July 10, 2017 10:21
-
-
Save RoystonS/92784110dc263de4eea5329142badc5d to your computer and use it in GitHub Desktop.
Sample complex file for parsing
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
Parsing stuff/TestComponent.ts | |
no tsconfig file specified - using default options | |
Component SimpleStatelessComponent: | |
bar: number | |
Component TestComponent: | |
children: ReactNode | |
thisIsAPropInASubtypeInterface: number | |
onSomething: (value: number) => void | |
thisIsAPropInABaseInterface: string | |
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 * as React from 'react'; | |
interface IMyPropsBase { | |
thisIsAPropInABaseInterface: string; | |
} | |
interface IMyProps extends IMyPropsBase { | |
thisIsAPropInASubtypeInterface: number; | |
onSomething(value: number): void; | |
} | |
interface ITheme { | |
} | |
interface IThemedProps { | |
theme: ITheme; | |
} | |
// A component which implements the IMyProps interface that I want | |
// to be public, but also accepts a theme property. | |
class MyComponent extends React.Component<IMyProps & IThemedProps, undefined> { | |
foobie: number; | |
} | |
// HoC function which takes a component with accepts props+themedprops and returns | |
// a component that just takes the props without the themedprops. | |
// (Dummy implementation that just returns its input) | |
function withTheme<ExternalProps, Theme>( | |
component: React.ComponentClass<ExternalProps & { theme: Theme }> | |
): React.ComponentClass<ExternalProps> { | |
return component; | |
} | |
interface IStatelessProps { | |
bar: number; | |
} | |
export function SimpleStatelessComponent(_props: IStatelessProps) { | |
return React.createElement('div'); | |
} | |
export default withTheme<IMyProps, ITheme>(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment