Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ register(Task.clean, [], (callback) => {
*/
register(Task.copy, [Task.scripts], () => {
return gulp.src(path.join(dirs.build, dirs.src, match(set(".d.ts", ".js"))))
.pipe(replace("/// <reference path=\"../typings/react/react.d.ts\" />", ""))
.pipe(replace("<reference path=\"../", "<reference path=\"./"))
.pipe(gulp.dest(dirs.cwd));
});

Expand Down Expand Up @@ -120,6 +120,7 @@ register(Task.scripts, [Task.clean], (callback) => {
sortOutput: false,
target: "ES5"
}));

drain(compiler.js);
drain(compiler.dts);
function drain(stream: NodeJS.ReadWriteStream): void {
Expand Down
6 changes: 4 additions & 2 deletions src/component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/// <reference path="../typings/react/react.d.ts"/>

import Mixin = require("././mixin");
import react = require("react");

class Component<P, S> extends Mixin<P, S> implements React.CompositeComponent<P, S> {
render(): React.ReactElement<any> {
class Component<P, S> extends Mixin<P, S> implements react.ClassicComponent<P, S> {
render(): react.ReactElement<any> {
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/create_class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import extractPrototype = require("./extract_prototype");
import Component = require("./component");
import react = require("react");

function createClass<P, S>(clazz: { new(): Component<P, S> }, mixins?: React.Mixin<P, S>[]): React.ComponentClass<P> {
var spec: React.ComponentSpec<P, S> = extractPrototype(clazz);
function createClass<P, S>(clazz: { new(): Component<P, S> }, mixins?: react.Mixin<P, S>[]): react.ComponentClass<P> {
var spec: react.ComponentSpec<P, S> = extractPrototype(clazz);
spec.displayName = clazz.prototype.constructor.name;
if (spec.componentWillMount !== undefined) {
var componentWillMount = spec.componentWillMount;
Expand Down
3 changes: 2 additions & 1 deletion src/create_mixin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/// <reference path="../typings/react/react.d.ts"/>
import extractPrototype = require("./extract_prototype");
import Mixin = require("./mixin");
import react = require("react");

function createMixin<P, S>(clazz: { new(): Mixin<P, S> }): React.Mixin<P, S> {
function createMixin<P, S>(clazz: { new(): Mixin<P, S> }): react.Mixin<P, S> {
return extractPrototype(clazz);
}

Expand Down
8 changes: 5 additions & 3 deletions src/mixin.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/// <reference path="../typings/react/react.d.ts"/>
import NotImplementedError = require("./not_implemented_error");
import react = require("react");

class Mixin<P, S> implements React.Mixin<P, S> {
class Mixin<P, S> implements react.Mixin<P, S> {
public refs: {
[key: string]: React.Component<any>
[key: string]: react.Component<any, any>
};
public props: P;
public state: S;
public context: any;

getDOMNode(): Element {
throw new NotImplementedError("getDomNode");
}

setState(nextState: S, callback?: () => void): void {
setState(nextState: S | ((prevState: S, props: P) => S), callback?: () => void): void {
throw new NotImplementedError("setState");
}

Expand Down
8 changes: 5 additions & 3 deletions test/create_class_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// <reference path="../typings/mocha/mocha.d.ts" />
/// <reference path="../typings/react/react.d.ts" />

import chai = require("chai");
import React = require("react");
import TypedReact = require("../src/index");
Expand Down Expand Up @@ -37,13 +39,13 @@ class LifeCycleMixin extends TypedReact.Mixin<FactoryProps, FactoryState> {
}

class HelperMixin extends TypedReact.Mixin<FactoryProps, FactoryState> {
greet(greeting: string): React.ReactHTMLElement {
greet(greeting: string): React.HTMLElement {
return React.DOM.h1(null, greeting, this.props.name);
}
}

class MixinTest extends FactoryTest implements HelperMixin {
greet: (greeting: string) => React.ReactHTMLElement;
greet: (greeting: string) => React.HTMLElement;

render() {
return this.greet(this.greeting);
Expand All @@ -52,7 +54,7 @@ class MixinTest extends FactoryTest implements HelperMixin {

describe("createFactory", () => {
var clazz: React.ComponentClass<FactoryProps>;
var factory: React.ComponentFactory<FactoryProps>;
var factory: React.Factory<FactoryProps>;
var element: React.ReactElement<FactoryProps>;
var name = "test";

Expand Down
2 changes: 1 addition & 1 deletion tsd.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"commit": "b5131a650f037aa1d962b9ff63a1bb929dc2dcf7"
},
"react/react.d.ts": {
"commit": "b5131a650f037aa1d962b9ff63a1bb929dc2dcf7"
"commit": "57340eca1e3aac68d59cc981b441da834ca38235"
},
"vinyl/vinyl.d.ts": {
"commit": "b5131a650f037aa1d962b9ff63a1bb929dc2dcf7"
Expand Down