From 0f022c99c78b3a9e12dcb0c53d93c9ccb38d714d Mon Sep 17 00:00:00 2001 From: Danila Date: Mon, 19 Sep 2016 00:13:36 +0400 Subject: [PATCH] Update deps and typings, disable hot reload --- .gitignore | 3 +- package.json | 18 +- server.js | 2 +- src/index.tsx | 4 +- typings/react/react-dom.d.ts | 2454 +++++++++++++++++++++++++++++++++- typings/react/react.d.ts | 755 ++++++----- 6 files changed, 2829 insertions(+), 407 deletions(-) diff --git a/.gitignore b/.gitignore index e8e8317..8412f46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -static/bundle.js \ No newline at end of file +static/bundle.js +.vscode diff --git a/package.json b/package.json index ff5193d..bc40fb0 100644 --- a/package.json +++ b/package.json @@ -23,16 +23,16 @@ }, "homepage": "http://mobxjs.github.com/mobx", "devDependencies": { - "ts-loader": "^0.8.1", - "typescript": "^1.8.2", - "webpack": "^1.9.6", - "webpack-dev-server": "^1.8.2" + "ts-loader": "^0.8.2", + "typescript": "^1.8.10", + "webpack": "^1.13.2", + "webpack-dev-server": "^1.16.1" }, "dependencies": { - "mobx": "^2.3.2", - "mobx-react": "^3.3.1", - "mobx-react-devtools": "^4.2.0", - "react": "^15.1.0", - "react-dom": "^15.1.0" + "mobx": "^2.5.1", + "mobx-react": "^3.5.6", + "mobx-react-devtools": "^4.2.6", + "react": "^15.3.1", + "react-dom": "^15.3.1" } } diff --git a/server.js b/server.js index 5ac2b33..9b9333c 100644 --- a/server.js +++ b/server.js @@ -4,7 +4,7 @@ var config = require('./webpack.config'); new WebpackDevServer(webpack(config), { publicPath: config.output.publicPath, - hot: true, + hot: false, historyApiFallback: true }).listen(3000, 'localhost', function (err, result) { if (err) { diff --git a/src/index.tsx b/src/index.tsx index c4f4eba..4f82d79 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,13 +6,13 @@ import DevTools from 'mobx-react-devtools'; class AppState { @observable timer = 0; - + constructor() { setInterval(() => { this.timer += 1; }, 1000); } - + resetTimer() { this.timer = 0; } diff --git a/typings/react/react-dom.d.ts b/typings/react/react-dom.d.ts index 80a0c60..89b86ab 100644 --- a/typings/react/react-dom.d.ts +++ b/typings/react/react-dom.d.ts @@ -1,66 +1,2418 @@ -// Type definitions for React v0.14 (react-dom) +// Generated by typings +// Source: https://raw.githubusercontent.com/cantide5ga/typed-react-dom/d498c5a1056d26babef04b56139628be1f59a357/server.d.ts +declare module '~react-dom/server' { +import { ReactElement } from '~react-dom~react'; + +namespace ReactDomServer { + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + var version: string; +} + +export = ReactDomServer; +} +declare module 'react-dom/server' { +import main = require('~react-dom/server'); +export = main; +} + +// Generated by typings +// Source: https://raw.githubusercontent.com/cantide5ga/typed-react/42692d400db3c333394ec75bce9f6d09b5a0a769/react.d.ts +declare module '~react-dom~react' { +// Type definitions for React v0.14 // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Typings: Michael N. Payne -/// +namespace React { -declare namespace __React { - namespace __DOM { - function findDOMNode(instance: ReactInstance): E; - function findDOMNode(instance: ReactInstance): Element; + // + // React Elements + // ---------------------------------------------------------------------- - function render

( - element: DOMElement

, - container: Element, - callback?: (element: Element) => any): Element; - function render( - element: ClassicElement

, - container: Element, - callback?: (component: ClassicComponent) => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: (component: Component) => any): Component; + type ReactType = string | ComponentClass | StatelessComponent; - function unmountComponentAtNode(container: Element): boolean; + type Key = string | number; + type Ref = string | ((instance: T) => any); + type ComponentState = {} | void; - var version: string; - - function unstable_batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; - function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; - function unstable_batchedUpdates(callback: () => any): void; - - function unstable_renderSubtreeIntoContainer

( - parentComponent: Component, - nextElement: DOMElement

, - container: Element, - callback?: (element: Element) => any): Element; - function unstable_renderSubtreeIntoContainer( - parentComponent: Component, - nextElement: ClassicElement

, - container: Element, - callback?: (component: ClassicComponent) => any): ClassicComponent; - function unstable_renderSubtreeIntoContainer( - parentComponent: Component, - nextElement: ReactElement

, - container: Element, - callback?: (component: Component) => any): Component; + interface Attributes { + key?: Key; + } + interface ClassAttributes extends Attributes { + ref?: Ref; } - namespace __DOMServer { - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; - var version: string; + interface ReactElement

{ + type: string | ComponentClass

| SFC

; + props: P; + key?: Key; + } + + interface SFCElement

extends ReactElement

{ + type: SFC

; + } + + type CElement> = ComponentElement; + interface ComponentElement> extends ReactElement

{ + type: ComponentClass

; + ref?: Ref; + } + + type ClassicElement

= CElement>; + + interface DOMElement

extends ReactElement

{ + type: string; + ref: Ref; + } + + interface ReactHTMLElement extends DOMElement { + } + + interface ReactSVGElement extends DOMElement { + } + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P & Attributes, ...children: ReactNode[]): ReactElement

; + } + + interface SFCFactory

{ + (props?: P & Attributes, ...children: ReactNode[]): SFCElement

; + } + + interface ComponentFactory> { + (props?: P & ClassAttributes, ...children: ReactNode[]): CElement; + } + + type CFactory> = ComponentFactory; + type ClassicFactory

= CFactory>; + + interface DOMFactory

{ + (props?: P & ClassAttributes, ...children: ReactNode[]): DOMElement; + } + + interface HTMLFactory extends DOMFactory { + } + + interface SVGFactory extends DOMFactory { + } + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

( + type: string): DOMFactory; + function createFactory

(type: SFC

): SFCFactory

; + function createFactory

( + type: ClassType, ClassicComponentClass

>): CFactory>; + function createFactory, C extends ComponentClass

>( + type: ClassType): CFactory; + function createFactory

(type: ComponentClass

| SFC

): Factory

; + + function createElement

( + type: string, + props?: P & ClassAttributes, + ...children: ReactNode[]): DOMElement; + function createElement

( + type: SFC

, + props?: P & Attributes, + ...children: ReactNode[]): SFCElement

; + function createElement

( + type: ClassType, ClassicComponentClass

>, + props?: P & ClassAttributes>, + ...children: ReactNode[]): CElement>; + function createElement, C extends ComponentClass

>( + type: ClassType, + props?: P & ClassAttributes, + ...children: ReactNode[]): CElement; + function createElement

( + type: ComponentClass

| SFC

, + props?: P & Attributes, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement, + props?: P & ClassAttributes, + ...children: ReactNode[]): DOMElement; + function cloneElement

( + element: SFCElement

, + props?: Q, // should be Q & Attributes, but then Q is inferred as {} + ...children: ReactNode[]): SFCElement

; + function cloneElement

>( + element: CElement, + props?: Q, // should be Q & ClassAttributes + ...children: ReactNode[]): CElement; + function cloneElement

( + element: ReactElement

, + props?: Q, // should be Q & Attributes + ...children: ReactNode[]): ReactElement

; + + function isValidElement

(object: {}): object is ReactElement

; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + type ReactInstance = Component | Element; + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): ReactElement; + + // React.Props is now deprecated, which means that the `children` + // property is not available on `P` by default, even though you can + // always pass children as variadic arguments to `createElement`. + // In the future, if we can define its call signature conditionally + // on the existence of `children` in `P`, then we should remove this. + props: P & { children?: ReactNode }; + state: S; + context: {}; + refs: { + [key: string]: ReactInstance + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + isMounted(): boolean; + getInitialState?(): S; + } + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + type SFC

= StatelessComponent

; + interface StatelessComponent

{ + (props?: P, context?: any): ReactElement; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + defaultProps?: P; + displayName?: string; + } + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + displayName?: string; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + } + + /** + * We use an intersection type to infer multiple type parameters from + * a single argument, which is useful for many top-level API defs. + * See https://github.com/Microsoft/TypeScript/issues/7234 for more info. + */ + type ClassType, C extends ComponentClass

> = + C & + (new() => T) & + (new() => { props: P }); + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface CompositionEvent extends SyntheticEvent { + data: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + type ReactEventHandler = EventHandler; + + type ClipboardEventHandler = EventHandler; + type CompositionEventHandler = EventHandler; + type DragEventHandler = EventHandler; + type FocusEventHandler = EventHandler; + type FormEventHandler = EventHandler; + type KeyboardEventHandler = EventHandler; + type MouseEventHandler = EventHandler; + type TouchEventHandler = EventHandler; + type UIEventHandler = EventHandler; + type WheelEventHandler = EventHandler; + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + /** + * @deprecated. This was used to allow clients to pass `ref` and `key` + * to `createElement`, which is no longer necessary due to intersection + * types. If you need to declare a props object before passing it to + * `createElement` or a factory, use `ClassAttributes`: + * + * ```ts + * var b: Button; + * var props: ButtonProps & ClassAttributes