diff --git a/types/react-gateway/Gateway.d.ts b/types/react-gateway/Gateway.d.ts new file mode 100644 index 0000000000..8fabcc95d5 --- /dev/null +++ b/types/react-gateway/Gateway.d.ts @@ -0,0 +1,9 @@ +import * as React from 'react'; + +declare namespace Gateway { + interface GatewayProps { + into: string; + } +} +declare class Gateway extends React.Component { } +export = Gateway; diff --git a/types/react-gateway/GatewayDest.d.ts b/types/react-gateway/GatewayDest.d.ts new file mode 100644 index 0000000000..4fd7928b2f --- /dev/null +++ b/types/react-gateway/GatewayDest.d.ts @@ -0,0 +1,11 @@ +import * as React from 'react'; + +declare namespace GatewayDest { + interface GatewayDestProps { + name: string; + tagName?: string; + component?: string | React.Component; + } +} +declare class GatewayDest extends React.Component { } +export = GatewayDest; diff --git a/types/react-gateway/GatewayProvider.d.ts b/types/react-gateway/GatewayProvider.d.ts new file mode 100644 index 0000000000..2d971539ea --- /dev/null +++ b/types/react-gateway/GatewayProvider.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; + +declare class GatewayProvider extends React.Component { } +export = GatewayProvider; diff --git a/types/react-gateway/GatewayRegistry.d.ts b/types/react-gateway/GatewayRegistry.d.ts new file mode 100644 index 0000000000..260a7e03be --- /dev/null +++ b/types/react-gateway/GatewayRegistry.d.ts @@ -0,0 +1,20 @@ +declare class GatewayRegistry { + _containers: { [name: string]: React.Component | null | undefined }; + _children: { [name: string]: { [gatewayId: string]: React.ReactNode } | undefined }; + _currentId: number; + + _renderContainer(name: string): void; + + addContainer(name: string, container: React.Component): void; + + removeContainer(name: string): void; + + addChild(name: string, gatewayId: string, child: React.ReactNode): void; + + clearChild(name: string, gatewayId: string): void; + + register(name: string, child: React.ReactNode): string; + + unregister(name: string, gatewayId: string): void; +} +export = GatewayRegistry; diff --git a/types/react-gateway/index.d.ts b/types/react-gateway/index.d.ts new file mode 100644 index 0000000000..7c90464019 --- /dev/null +++ b/types/react-gateway/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for react-gateway 2.8 +// Project: https://github.com/cloudflare/react-gateway +// Definitions by: Jason Unger +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import Gateway = require('./Gateway'); +import { GatewayProps } from './Gateway'; +import GatewayDest = require('./GatewayDest'); +import { GatewayDestProps } from './GatewayDest'; +import GatewayProvider = require('./GatewayProvider'); +import GatewayRegistry = require('./GatewayRegistry'); + +export { + Gateway, + GatewayProps, + GatewayDest, + GatewayDestProps, + GatewayProvider, + GatewayRegistry +}; diff --git a/types/react-gateway/react-gateway-tests.tsx b/types/react-gateway/react-gateway-tests.tsx new file mode 100644 index 0000000000..bbf24dd741 --- /dev/null +++ b/types/react-gateway/react-gateway-tests.tsx @@ -0,0 +1,36 @@ +import * as React from 'react'; +import { Gateway, GatewayProvider, GatewayDest } from 'react-gateway'; + +class ReactGateway extends React.Component { + render() { + return ( + +
+ Text goes here. +
+
+ ); + } +} + +class ReactGatewayProvider extends React.Component { + render() { + return ( + + +
+ All the way down... +
+ Almost there... +
+ Getting close... +
+ +
+
+
+
+
+ ); + } +} diff --git a/types/react-gateway/tsconfig.json b/types/react-gateway/tsconfig.json new file mode 100644 index 0000000000..58ecf35a63 --- /dev/null +++ b/types/react-gateway/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "Gateway.d.ts", + "GatewayDest.d.ts", + "GatewayProvider.d.ts", + "GatewayRegistry.d.ts", + "index.d.ts", + "react-gateway-tests.tsx" + ] +} diff --git a/types/react-gateway/tslint.json b/types/react-gateway/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-gateway/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }