Skip to content

Instantly share code, notes, and snippets.

@hasparus
Last active August 28, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasparus/91c4573c5ab4bdc73e3d3494d35add68 to your computer and use it in GitHub Desktop.
Save hasparus/91c4573c5ab4bdc73e3d3494d35add68 to your computer and use it in GitHub Desktop.
import { ComponentClass, ComponentType, Ref } from 'react';
export type Fixture<T extends ComponentType<any>> = {
component: T;
init?: (arg: { compRef: Ref<T> }) => Promise<any>;
name?: string;
namespace?: string;
props: T extends ComponentType<infer X> ? X : never;
state?: T extends ComponentClass<any, infer S> ? S : never;
};
export function createFixture<T extends ComponentType<any>>(
fixture: Fixture<T>
): Fixture<T> {
return fixture;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment