Fix linting errors in react typings

This commit is contained in:
Adi Dahiya
2015-11-16 17:38:29 -05:00
parent fc341765eb
commit ca5bfe76d2
11 changed files with 61 additions and 62 deletions

View File

@@ -212,7 +212,7 @@ declare namespace __React {
displayName?: string;
propTypes?: ValidationMap<any>;
contextTypes?: ValidationMap<any>;
childContextTypes?: ValidationMap<any>
childContextTypes?: ValidationMap<any>;
getDefaultProps?(): P;
getInitialState?(): S;
@@ -591,7 +591,7 @@ declare namespace __React {
x2?: number | string;
x?: number | string;
y1?: number | string;
y2?: number | string
y2?: number | string;
y?: number | string;
}
@@ -1021,7 +1021,7 @@ declare module "react/addons" {
displayName?: string;
propTypes?: ValidationMap<any>;
contextTypes?: ValidationMap<any>;
childContextTypes?: ValidationMap<any>
childContextTypes?: ValidationMap<any>;
getDefaultProps?(): P;
getInitialState?(): S;
@@ -1399,7 +1399,7 @@ declare module "react/addons" {
x2?: number | string;
x?: number | string;
y1?: number | string;
y2?: number | string
y2?: number | string;
y?: number | string;
}

View File

@@ -7,7 +7,6 @@
/// <reference path="react-addons-transition-group.d.ts" />
declare namespace __React {
interface CSSTransitionGroupTransitionName {
enter: string;
enterActive?: string;
@@ -16,16 +15,16 @@ declare namespace __React {
appear?: string;
appearActive?: string;
}
interface CSSTransitionGroupProps extends TransitionGroupProps {
transitionName: string | CSSTransitionGroupTransitionName;
transitionAppear?: boolean;
transitionEnter?: boolean;
transitionLeave?: boolean;
}
type CSSTransitionGroup = ComponentClass<CSSTransitionGroupProps>;
namespace __Addons {
export var CSSTransitionGroup: __React.CSSTransitionGroup;
}

View File

@@ -10,7 +10,7 @@ declare namespace __React {
value: T;
requestChange(newValue: T): void;
}
interface LinkedStateMixin extends Mixin<any, any> {
linkState<T>(key: string): ReactLink<T>;
}
@@ -19,7 +19,7 @@ declare namespace __React {
checkedLink?: ReactLink<boolean>;
valueLink?: ReactLink<boolean | string | number>;
}
namespace __Addons {
export var LinkedStateMixin: LinkedStateMixin;
}

View File

@@ -26,7 +26,7 @@ declare namespace __React {
};
totalTime: number;
}
namespace __Addons {
namespace Perf {
export function start(): void;

View File

@@ -7,7 +7,7 @@
declare namespace __React {
interface PureRenderMixin extends Mixin<any, any> {}
namespace __Addons {
export var PureRenderMixin: PureRenderMixin;
}

View File

@@ -44,18 +44,18 @@ declare namespace __React {
(element: Element, eventData?: SyntheticEventData): void;
(component: Component<any, any>, eventData?: SyntheticEventData): void;
}
interface MockedComponentClass {
new(): any;
}
class ShallowRenderer {
getRenderOutput<E extends ReactElement<any>>(): E;
getRenderOutput(): ReactElement<any>;
render(element: ReactElement<any>, context?: any): void;
unmount(): void;
}
namespace __Addons {
namespace TestUtils {
namespace Simulate {
@@ -93,17 +93,17 @@ declare namespace __React {
export var touchStart: EventSimulator;
export var wheel: EventSimulator;
}
export function renderIntoDocument(
element: DOMElement<any>): Element;
export function renderIntoDocument<P>(
element: ReactElement<P>): Component<P, any>;
export function renderIntoDocument<C extends Component<any, any>>(
element: ReactElement<any>): C;
export function mockComponent(
mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils;
export function isElementOfType(
element: ReactElement<any>, type: ReactType): boolean;
export function isDOMComponent(instance: ReactInstance): boolean;
@@ -111,39 +111,39 @@ declare namespace __React {
export function isCompositeComponentWithType(
instance: ReactInstance,
type: ComponentClass<any>): boolean;
export function findAllInRenderedTree(
root: Component<any, any>,
fn: (i: ReactInstance) => boolean): ReactInstance[];
export function scryRenderedDOMComponentsWithClass(
root: Component<any, any>,
className: string): Element[];
export function findRenderedDOMComponentWithClass(
root: Component<any, any>,
className: string): Element;
export function scryRenderedDOMComponentsWithTag(
root: Component<any, any>,
tagName: string): Element[];
export function findRenderedDOMComponentWithTag(
root: Component<any, any>,
tagName: string): Element;
export function scryRenderedComponentsWithType<P>(
root: Component<any, any>,
type: ComponentClass<P>): Component<P, {}>[];
export function scryRenderedComponentsWithType<C extends Component<any, any>>(
root: Component<any, any>,
type: ComponentClass<any>): C[];
export function findRenderedComponentWithType<P>(
root: Component<any, any>,
type: ComponentClass<P>): Component<P, {}>;
export function findRenderedComponentWithType<C extends Component<any, any>>(
root: Component<any, any>,
type: ComponentClass<any>): C;
export function createRenderer(): ShallowRenderer;
}
}

View File

@@ -23,7 +23,7 @@ declare namespace __React {
$unshift?: any[];
$splice?: any[][];
}
namespace __Addons {
export function update(value: any[], spec: UpdateArraySpec): any[];
export function update(value: {}, spec: UpdateSpec): any;

13
react/react-dom.d.ts vendored
View File

@@ -6,11 +6,10 @@
/// <reference path="react.d.ts" />
declare namespace __React {
namespace __DOM {
function findDOMNode<E extends Element>(instance: ReactInstance): E;
function findDOMNode(instance: ReactInstance): Element;
function render<P>(
element: DOMElement<P>,
container: Element,
@@ -23,15 +22,15 @@ declare namespace __React {
element: ReactElement<P>,
container: Element,
callback?: (component: Component<P, S>) => any): Component<P, S>;
function unmountComponentAtNode(container: Element): boolean;
var version: string;
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
function unstable_batchedUpdates(callback: () => any): void;
function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any, any>,
nextElement: DOMElement<P>,
@@ -48,7 +47,7 @@ declare namespace __React {
container: Element,
callback?: (component: Component<P, S>) => any): Component<P, S>;
}
namespace __DOMServer {
function renderToString(element: ReactElement<any>): string;
function renderToStaticMarkup(element: ReactElement<any>): string;

View File

@@ -68,34 +68,34 @@ var ClassicComponent: React.ClassicComponentClass<Props> =
class ModernComponent extends React.Component<Props, State>
implements React.ChildContextProvider<ChildContext> {
static propTypes: React.ValidationMap<Props> = {
foo: React.PropTypes.number
}
};
static contextTypes: React.ValidationMap<Context> = {
someValue: React.PropTypes.string
}
};
static childContextTypes: React.ValidationMap<ChildContext> = {
someOtherValue: React.PropTypes.string
}
};
static defaultProps: Props;
context: Context;
getChildContext() {
return {
someOtherValue: 'foo'
}
someOtherValue: "foo"
};
}
state = {
inputValue: this.context.someValue,
seconds: this.props.foo
}
};
reset() {
this.setState({
inputValue: this.context.someValue,
@@ -104,7 +104,7 @@ class ModernComponent extends React.Component<Props, State>
}
private _input: HTMLInputElement;
render() {
return React.DOM.div(null,
React.DOM.input({
@@ -342,7 +342,7 @@ interface TimerState {
class Timer extends React.Component<{}, TimerState> {
state = {
secondsElapsed: 0
}
};
private _interval: number;
tick() {
this.setState((prevState, props) => ({
@@ -392,7 +392,7 @@ React.createFactory(React.addons.CSSTransitionGroup)({
// --------------------------------------------------------------------------
React.createClass({
mixins: [React.addons.LinkedStateMixin],
render: function() { return React.DOM.div(null) }
render: function() { return React.DOM.div(null); }
});
//
@@ -411,7 +411,7 @@ React.addons.Perf.printDOM(measurements);
// --------------------------------------------------------------------------
React.createClass({
mixins: [React.addons.PureRenderMixin],
render: function() { return React.DOM.div(null) }
render: function() { return React.DOM.div(null); }
});
//
@@ -427,7 +427,7 @@ var renderer: React.ShallowRenderer =
renderer.render(React.createElement(Timer));
var output: React.ReactElement<React.Props<Timer>> =
renderer.getRenderOutput();
//
// TransitionGroup addon
// --------------------------------------------------------------------------
@@ -437,7 +437,7 @@ React.createFactory(React.addons.TransitionGroup)({ component: "div" });
// update addon
// --------------------------------------------------------------------------
{
// These are copied from https://facebook.github.io/react/docs/update.html
// These are copied from https://facebook.github.io/react/docs/update.html
let initialArray = [1, 2, 3];
let newArray = React.addons.update(initialArray, {$push: [4]}); // => [1, 2, 3, 4]

View File

@@ -9,6 +9,7 @@
/// <reference path="react-addons-test-utils.d.ts" />
/// <reference path="react-addons-transition-group.d.ts" />
/// <reference path="react-addons-update.d.ts" />
import React = require("react");
import ReactDOM = require("react-dom");
import ReactDOMServer = require("react-dom/server");
@@ -90,28 +91,28 @@ class ModernComponent extends React.Component<Props, State>
static propTypes: React.ValidationMap<Props> = {
foo: React.PropTypes.number
}
};
static contextTypes: React.ValidationMap<Context> = {
someValue: React.PropTypes.string
}
};
static childContextTypes: React.ValidationMap<ChildContext> = {
someOtherValue: React.PropTypes.string
}
};
context: Context;
getChildContext() {
return {
someOtherValue: 'foo'
}
someOtherValue: "foo"
};
}
state = {
inputValue: this.context.someValue,
seconds: this.props.foo
}
};
reset() {
this._myComponent.reset();
@@ -417,7 +418,7 @@ interface TimerState {
class Timer extends React.Component<{}, TimerState> {
state = {
secondsElapsed: 0
}
};
private _interval: number;
tick() {
this.setState((prevState, props) => ({
@@ -514,7 +515,7 @@ Perf.printDOM(measurements);
// --------------------------------------------------------------------------
React.createClass({
mixins: [PureRenderMixin],
render: function() { return React.DOM.div(null) }
render: function() { return React.DOM.div(null); }
});
//

4
react/react.d.ts vendored
View File

@@ -187,7 +187,7 @@ declare namespace __React {
displayName?: string;
propTypes?: ValidationMap<any>;
contextTypes?: ValidationMap<any>;
childContextTypes?: ValidationMap<any>
childContextTypes?: ValidationMap<any>;
getDefaultProps?(): P;
getInitialState?(): S;
@@ -655,7 +655,7 @@ declare namespace __React {
xmlLang?: string;
xmlSpace?: string;
y1?: number | string;
y2?: number | string
y2?: number | string;
y?: number | string;
}