mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
mobservable-react: Provides its own types (#15648)
This commit is contained in:
@@ -270,6 +270,12 @@
|
||||
"sourceRepoURL": "github.com/mweststrate/mobservable",
|
||||
"asOfVersion": "1.2.5"
|
||||
},
|
||||
{
|
||||
"libraryName": "mobservable-react",
|
||||
"typingsPackageName": "mobservable-react",
|
||||
"sourceRepoURL": "https://github.com/mweststrate/mobservable-react",
|
||||
"asOfVersion": "1.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Moment",
|
||||
"typingsPackageName": "moment",
|
||||
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
// Type definitions for mobservable v0.1.8
|
||||
// Project: https://github.com/mweststrate/mobservable-react
|
||||
// Definitions by: Michel Weststrate <https://github.com/mweststrate/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* Turns a React component or stateless render function into a reactive component.
|
||||
*/
|
||||
export function reactiveComponent<P>(clazz: React.ClassicComponentClass<P>): React.ClassicComponentClass<P>;
|
||||
export function reactiveComponent<TFunction extends React.ComponentClass<any>>(target: TFunction): void; // decorator signature
|
||||
export function reactiveComponent<P>(clazz: React.ComponentClass<P>): React.ComponentClass<P>;
|
||||
export function reactiveComponent<P>(renderFunction: (props: P) => React.ReactElement<any>): React.ClassicComponentClass<P>;
|
||||
@@ -1,60 +0,0 @@
|
||||
import {reactiveComponent} from 'mobservable-react';
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
|
||||
{
|
||||
let c1 = reactiveComponent(React.createClass({
|
||||
getDefaultProps() {
|
||||
return {
|
||||
test: "hi"
|
||||
};
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return React.createElement("div");
|
||||
}
|
||||
}));
|
||||
|
||||
let c1Factory = React.createFactory(c1);
|
||||
ReactDOM.render(c1Factory({
|
||||
test: "hello"
|
||||
}), null);
|
||||
}
|
||||
|
||||
@reactiveComponent
|
||||
class TestComponent extends React.Component<{ test: string },{}> {
|
||||
render() {
|
||||
return React.createElement("div");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let c2Factory = React.createFactory(TestComponent);
|
||||
ReactDOM.render(c2Factory({
|
||||
test: "hello"
|
||||
}) , null);
|
||||
}
|
||||
|
||||
{
|
||||
var c3 = reactiveComponent((props: { test: string }) => React.createElement("div"));
|
||||
var c3Factory = React.createFactory(c3); //without JSX
|
||||
ReactDOM.render(c3Factory({
|
||||
test: "hello"
|
||||
}), null);
|
||||
}
|
||||
|
||||
|
||||
class TestComponent2 extends React.Component<{ test: string },{}> {
|
||||
render() {
|
||||
return React.createElement("div");
|
||||
}
|
||||
}
|
||||
{
|
||||
// Does not work properly in typescript 1.6.2 without cast :'(
|
||||
// Argument of type 'typeof TestComponent2 | void' is not assignable to parameter of type 'ComponentClass<{ test: string; }>'.
|
||||
// Type 'void' is not assignable to type 'ComponentClass<{ test: string; }>'.
|
||||
let c4Factory = React.createFactory(<React.ClassicComponentClass<{test:string}>><any> reactiveComponent(TestComponent2));
|
||||
ReactDOM.render(c4Factory({
|
||||
test: "hello"
|
||||
}) , null);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"experimentalDecorators": true,
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mobservable-react-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user