Add types for react-gateway@2.8 (#27029)

* Add types for react-gateway@2.8

* Fix linting

* Remove unnecessary lib folder
This commit is contained in:
Jason Unger 2018-07-03 18:11:12 -04:00 committed by Mohamed Hegazy
parent 9c7050dd4c
commit 9e79023693
8 changed files with 130 additions and 0 deletions

9
types/react-gateway/Gateway.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
import * as React from 'react';
declare namespace Gateway {
interface GatewayProps {
into: string;
}
}
declare class Gateway extends React.Component<Gateway.GatewayProps> { }
export = Gateway;

11
types/react-gateway/GatewayDest.d.ts vendored Normal file
View File

@ -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<GatewayDest.GatewayDestProps> { }
export = GatewayDest;

View File

@ -0,0 +1,4 @@
import * as React from 'react';
declare class GatewayProvider extends React.Component { }
export = GatewayProvider;

View File

@ -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;

21
types/react-gateway/index.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
// Type definitions for react-gateway 2.8
// Project: https://github.com/cloudflare/react-gateway
// Definitions by: Jason Unger <https://github.com/jsonunger>
// 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
};

View File

@ -0,0 +1,36 @@
import * as React from 'react';
import { Gateway, GatewayProvider, GatewayDest } from 'react-gateway';
class ReactGateway extends React.Component<Gateway.GatewayProps> {
render() {
return (
<Gateway {...this.props}>
<div>
Text goes here.
</div>
</Gateway>
);
}
}
class ReactGatewayProvider extends React.Component {
render() {
return (
<GatewayProvider>
<GatewayDest name="test" />
<div>
All the way down...
<div>
Almost there...
<div>
Getting close...
<div>
<ReactGateway into="test" />
</div>
</div>
</div>
</div>
</GatewayProvider>
);
}
}

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }