From 8959bd86fa8b729f7156fa4199b3ab47b09a50ff Mon Sep 17 00:00:00 2001 From: prakarshpandey Date: Tue, 27 Jun 2017 18:17:03 -0700 Subject: [PATCH] Created type definitions for react-app --- types/react-app/index.d.ts | 40 +++++++++++++++++++++++++++++ types/react-app/react-app-tests.tsx | 38 +++++++++++++++++++++++++++ types/react-app/tsconfig.json | 23 +++++++++++++++++ types/react-app/tslint.json | 1 + 4 files changed, 102 insertions(+) create mode 100644 types/react-app/index.d.ts create mode 100644 types/react-app/react-app-tests.tsx create mode 100644 types/react-app/tsconfig.json create mode 100644 types/react-app/tslint.json diff --git a/types/react-app/index.d.ts b/types/react-app/index.d.ts new file mode 100644 index 0000000000..3fee3b6cf7 --- /dev/null +++ b/types/react-app/index.d.ts @@ -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 +// 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; +export const Layout: React.ComponentClass; +export const Header: React.ComponentClass<{}>; +export const Navigation: React.ComponentClass<{}>; diff --git a/types/react-app/react-app-tests.tsx b/types/react-app/react-app-tests.tsx new file mode 100644 index 0000000000..f19b436412 --- /dev/null +++ b/types/react-app/react-app-tests.tsx @@ -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:

Foo!

+ }; + } + }, + barRoute: { + path: '/bar', + action() { + return { + title: 'Bar Page', + component:

Bar!

+ }; + } + } + } +}; + +; +; +
; +; + +createApp({ + routes, + context: { store }, + container: document.body +}); diff --git a/types/react-app/tsconfig.json b/types/react-app/tsconfig.json new file mode 100644 index 0000000000..3a673038be --- /dev/null +++ b/types/react-app/tsconfig.json @@ -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" + ] +} diff --git a/types/react-app/tslint.json b/types/react-app/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-app/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }