fix spacing (4 spaces). Implement the test. Add reference to react.d.ts

This commit is contained in:
Carlo Cancellieri
2016-07-07 10:36:54 +02:00
parent 9757c2f96c
commit f5790919f2
5 changed files with 80 additions and 27 deletions

View File

@@ -277,4 +277,3 @@ class SomeClass extends Component<any, any> {
public bar: number;
}
let bar: number = new (connect()(SomeClass))("foo").bar;

View File

@@ -1,6 +0,0 @@
// Tests for type definitions for react-user-tour
// Project: https://github.com/socialtables/react-user-tour
// Definitions by: Carlo Cancellieri <https://github.com/ccancellieri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="react-user-tour.d.ts" />

View File

@@ -0,0 +1,57 @@
// Tests for type definitions for react-user-tour
// Project: https://github.com/socialtables/react-user-tour
// Definitions by: Carlo Cancellieri <https://github.com/ccancellieri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="react-user-tour.d.ts" />
/// <reference path="../react/react.d.ts" />
/// <reference path="../react/react-dom.d.ts" />
import React = require("react");
import ReactDOM = require("react-dom");
import ReactUserTour from "react-user-tour";
interface State {
tourStep:number
isTourActive:boolean
}
class TestApp extends React.Component<{}, State> {
constructor(p:any){
super(p)
this.setState({
isTourActive:true,
tourStep:1
})
}
render() {
const Tour = <ReactUserTour active={this.state.isTourActive}
step={this.state.tourStep}
onNext={(step:number) => this.setState({tourStep: step, isTourActive: true})}
onBack={(step:number) => this.setState({tourStep: step, isTourActive: true})}
onCancel={() => this.setState({tourStep: this.state.tourStep, isTourActive: false})}
steps={[
{
step: 1,
selector: ".MyClass",
title: <div>React User Tour</div>,
body: <div>Provide a simple guided tour around a website utilizing css selectors.</div>,
position: "bottom"
}
]}
/>
return <div id='test-app' class='.MyClass'>
{Tour}
</div>
}
}
ReactDOM.render(React.createElement(TestApp, {}), document.getElementById("test-app"));

View File

@@ -0,0 +1 @@
--noImplicitAny --jsx react

View File

@@ -3,28 +3,30 @@
// Definitions by: Carlo Cancellieri <https://github.com/ccancellieri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
declare module "react-user-tour" {
// Import React
import { HTMLAttributes, ComponentClass } from 'react';
interface TourStep {
step: number
selector: string
title: string
body: string
position?: string
}
// Import React
import { HTMLAttributes, ComponentClass } from 'react';
interface TourProps extends HTMLAttributes {
steps:TourStep[]
active:boolean
step:number
onNext:any
onBack:any
onCancel:any
}
interface TourStep {
step: number
selector: string
title: string
body: string
position?: string
}
var ReactUserTour: ComponentClass<TourProps>;
export default ReactUserTour
interface TourProps extends HTMLAttributes {
steps:TourStep[]
active:boolean
step:number
onNext:any
onBack:any
onCancel:any
}
var ReactUserTour: ComponentClass<TourProps>;
export default ReactUserTour
}