Merge pull request #32327 from chrisdopuch/master

[single-spa-react] Avoids error when using custom props for rootComponent
This commit is contained in:
Benjamin Lichtman
2019-01-22 16:15:18 -08:00
committed by GitHub
4 changed files with 45 additions and 38 deletions
+20 -17
View File
@@ -1,29 +1,32 @@
// Type definitions for single-spa-react 2.8
// Project: https://github.com/CanopyTax/single-spa-react
// Definitions by: Garrett Smith <https://github.com/Garrett-Smith-iq>
// Chris Dopuch <https://github.com/chrisdopuch>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as React from "react";
import * as ReactDOM from "react-dom";
export = SingleSpaReact;
declare function SingleSpaReact(opts: SingleSpaReact.Options): SingleSpaReact.Lifecycles;
declare function SingleSpaReact(
opts: SingleSpaReact.Options
): SingleSpaReact.Lifecycles;
declare namespace SingleSpaReact {
interface Options {
React: typeof React;
ReactDOM: typeof ReactDOM;
rootComponent?: React.ComponentClass;
loadRootComponent?: () => Promise<React.ComponentClass>;
domElementGetter?: () => Element;
suppressComponentDidCatchWarning?: boolean;
parcelCanUpdate?: boolean;
}
interface Options {
React: typeof React;
ReactDOM: typeof ReactDOM;
rootComponent?: React.ComponentClass<any, any>;
loadRootComponent?: () => Promise<React.ComponentClass<any, any>>;
domElementGetter?: () => Element;
suppressComponentDidCatchWarning?: boolean;
parcelCanUpdate?: boolean;
}
interface Lifecycles {
bootstrap: (opts: Options, props: any) => Promise<void>;
mount: (opts: Options, props: any) => Promise<void>;
unmount: (opts: Options, props: any) => Promise<void>;
}
interface Lifecycles {
bootstrap: (props: any) => Promise<void>;
mount: (props: any) => Promise<void>;
unmount: (props: any) => Promise<void>;
}
}
@@ -1,10 +0,0 @@
import singleSpaReact = require('single-spa-react');
import { Lifecycles } from 'single-spa-react';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
// $ExpectType Lifecycles
singleSpaReact({
React,
ReactDOM,
});
@@ -0,0 +1,21 @@
import singleSpaReact = require("single-spa-react");
import { Lifecycles } from "single-spa-react";
import * as React from "react";
import * as ReactDOM from "react-dom";
interface customProps {
name: string;
}
class rootComponent extends React.Component<customProps> {
render() {
return <div> hello{this.props.name} !</div>;
}
}
// $ExpectType Lifecycles
singleSpaReact({
React,
ReactDOM,
rootComponent
});
+4 -11
View File
@@ -1,24 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"lib": ["es6", "dom"],
"jsx": "react",
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"single-spa-react-tests.ts"
]
"files": ["index.d.ts", "single-spa-react-tests.tsx"]
}