mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-17 22:44:18 +08:00
Created type definitions for react-app
This commit is contained in:
40
types/react-app/index.d.ts
vendored
Normal file
40
types/react-app/index.d.ts
vendored
Normal 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<{}>;
|
||||
38
types/react-app/react-app-tests.tsx
Normal file
38
types/react-app/react-app-tests.tsx
Normal 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
|
||||
});
|
||||
23
types/react-app/tsconfig.json
Normal file
23
types/react-app/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/react-app/tslint.json
Normal file
1
types/react-app/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user