Created type definitions for react-app

This commit is contained in:
prakarshpandey
2017-06-27 18:17:03 -07:00
parent c126a9ec44
commit 8959bd86fa
4 changed files with 102 additions and 0 deletions

40
types/react-app/index.d.ts vendored Normal file
View File

@@ -0,0 +1,40 @@
// Type definitions for react-app 1.0.0-alpha.3
// Project: https://github.com/kriasoft/react-app#readme
// Definitions by: Prakarsh Pandey <https://github.com/prakarshpandey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as React from 'react';
export interface LinkProps {
to: string | object;
onClick?(): void;
className?: string;
}
export interface LayoutProps {
className: string;
}
export interface RouteProps { // takes the form of universal-router routes
path: string;
children: ChildProps[];
}
export interface ChildProps {
path: string;
action(params: any): object;
}
export interface CreateAppObject {
routes: RouteProps;
context: object;
container: Element | null;
}
// exporting the createApp function
export function createApp(createAppObject: CreateAppObject): JSX.Element;
export const Link: React.ComponentClass<LinkProps>;
export const Layout: React.ComponentClass<LayoutProps>;
export const Header: React.ComponentClass<{}>;
export const Navigation: React.ComponentClass<{}>;

View File

@@ -0,0 +1,38 @@
import * as React from 'react';
import { Navigation, Link, Layout, Header, createApp } from './index';
const store = {};
const routes = {
path: '/',
children: {
fooRoute: {
path = '/',
action() {
return {
title: 'Foo Page',
component: <h1>Foo!</h1>
};
}
},
barRoute: {
path: '/bar',
action() {
return {
title: 'Bar Page',
component: <h1>Bar!</h1>
};
}
}
}
};
<Link to="/bar" className="a-link"/>;
<Layout className="my-layout"/>;
<Header />;
<Navigation />;
createApp({
routes,
context: { store },
container: document.body
});

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-app-tests.ts"
]
}

View File

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