diff --git a/types/storybook__react-native/index.d.ts b/types/storybook__react-native/index.d.ts new file mode 100644 index 0000000000..4bcd20ec30 --- /dev/null +++ b/types/storybook__react-native/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for @storybook/react-native 3.0 +// Project: https://github.com/storybooks/storybook +// Definitions by: Joscha Feth +// Anton Izmailov +// Alec Hill +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as Storybook from '@storybook/react'; + +export = Storybook; diff --git a/types/storybook__react-native/storybook__react-native-tests.tsx b/types/storybook__react-native/storybook__react-native-tests.tsx new file mode 100644 index 0000000000..7540a2f3e8 --- /dev/null +++ b/types/storybook__react-native/storybook__react-native-tests.tsx @@ -0,0 +1,37 @@ +import * as React from 'react'; +import { storiesOf, setAddon, addDecorator, configure, getStorybook, RenderFunction, Story } from '@storybook/react-native'; + +const Decorator = (story: RenderFunction) =>
{story()}
; + +storiesOf('Welcome', module) + // local addDecorator + .addDecorator(Decorator) + .add('to Storybook', () =>
) + .add('to Storybook as Array', () => [
,
]); + +// global addDecorator +addDecorator(Decorator); + +// setAddon +interface AnyAddon { + addWithSideEffect(this: Story & T, storyName: string, storyFn: RenderFunction): Story & T; +} +const AnyAddon: AnyAddon = { + addWithSideEffect(this: Story & T, storyName: string, storyFn: RenderFunction): Story & T { + console.log(this.kind === 'withAnyAddon'); + return this.add(storyName, storyFn); + } +}; +setAddon(AnyAddon); +storiesOf('withAnyAddon', module) + .addWithSideEffect('custom story', () =>
) + .addWithSideEffect('more', () =>
) + .add('another story', () =>
) + .add('to Storybook as Array', () => [
,
]) + .addWithSideEffect('even more', () =>
); + +// configure +configure(() => undefined, module); + +// getStorybook +getStorybook().forEach(({ kind, stories }) => stories.forEach(({ name, render }) => render())); diff --git a/types/storybook__react-native/tsconfig.json b/types/storybook__react-native/tsconfig.json new file mode 100644 index 0000000000..bba1a459fa --- /dev/null +++ b/types/storybook__react-native/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "paths": { + "@storybook/react-native": [ + "storybook__react-native" + ], + "@storybook/react": [ + "storybook__react" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "storybook__react-native-tests.tsx" + ] +} diff --git a/types/storybook__react-native/tslint.json b/types/storybook__react-native/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/storybook__react-native/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}