diff --git a/types/react-broadcast/index.d.ts b/types/react-broadcast/index.d.ts new file mode 100644 index 0000000000..8a9a3bf47b --- /dev/null +++ b/types/react-broadcast/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for react-broadcast 0.6 +// Project: https://github.com/ReactTraining/react-broadcast +// Definitions by: Jaga Santagostino +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from 'react'; + +export namespace Subscriber { + interface DefaultProps { + quiet: boolean; + } + interface Props extends Partial { + channel: string; + children?: ((state: T) => React.ReactNode); + } +} + +export namespace Broadcast { + interface DefaultProps { + compareValues: (prevValue: T, nextValue: T) => boolean; + } + interface Props extends Partial> { + channel: string; + children: React.ReactNode; + value: T; + } +} + +export class Broadcast extends React.Component, any> { } +export class Subscriber extends React.Component, any> { } diff --git a/types/react-broadcast/react-broadcast-tests.tsx b/types/react-broadcast/react-broadcast-tests.tsx new file mode 100644 index 0000000000..6f3466e729 --- /dev/null +++ b/types/react-broadcast/react-broadcast-tests.tsx @@ -0,0 +1,17 @@ +import * as React from 'react'; +import { Broadcast, Subscriber } from 'react-broadcast'; + +class ExampleOfUsingReactBroadcast extends React.Component { + render() { + const value = 42; + return ( + +
+ + {state =>
{state}
} +
+
+
+ ); + } +} diff --git a/types/react-broadcast/tsconfig.json b/types/react-broadcast/tsconfig.json new file mode 100644 index 0000000000..270151cc33 --- /dev/null +++ b/types/react-broadcast/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "strictNullChecks": true, + "strictFunctionTypes": false, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": ["index.d.ts", "react-broadcast-tests.tsx"] +} diff --git a/types/react-broadcast/tslint.json b/types/react-broadcast/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/react-broadcast/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}