Skip to content

Commit

Permalink
Added typescript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed Apr 18, 2017
1 parent 6c47093 commit 40442fa
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# CHANGELOG

# 4.0.1 (...)
# 4.0.1 (April 17th, 2017)

- Made compatible with React 15.5
- Added typescript definitions

# 4.0.0 (March 22th, 2017)

Expand Down
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export as namespace ReactRouterServer;
export = ReactRouterServer;

import { Component, ReactElement, ReactNode } from 'react';

declare namespace ReactRouterServer {
type ExtractedModule = {
id: string,
files: Array<any>;
};
function extractModules(modules: Array<any>, stats: any): Array<ExtractedModule>;

function fetchState<P, S>(mapStateToProps?: (state: any) => any, mapActionsToProps?: (actions: { done: (state: any) => void }) => any): Component<P, S>;

interface ModuleProps {
module: () => any;
children?: (module: any) => any;
}

class Module<P extends ModuleProps, S> extends Component<P, S> {
}

function preload(modules: any): Promise<any>;

function renderToString(element: ReactElement<any>): Promise<{ html: string, modules: any, state: any }>;

function renderToStaticMarkup(element: ReactElement<any>): Promise<{ html: string, modules: any, state: any }>;

interface ServerStateProviderProps {
state?: any;
children?: ReactNode;
}

class ServerStateProvider<P extends ServerStateProviderProps, S> extends Component<P, S> {
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "react-router-server",
"author": "Gabriel Bull",
"version": "4.0.0",
"version": "4.0.1",
"description": "Server Side Rendering library for React Router v4",
"main": "./build/index.js",
"types": "./index.d.ts",
"keywords": [
"code-splitting",
"react",
Expand Down Expand Up @@ -34,6 +35,7 @@
"react-router": "^4.0"
},
"devDependencies": {
"@types/react": "^15.0.22",
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/fetchState.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import isNode from '../utils/isNode';

export default (mapStateToProps, mapActionsToProps) => WrappedComponent =>{
export default (mapStateToProps, mapActionsToProps) => WrappedComponent => {
return class extends Component {
static contextTypes = {
reactRouterServerAsyncRenderer: () => null,
Expand Down

0 comments on commit 40442fa

Please sign in to comment.