diff --git a/types/single-spa-react/index.d.ts b/types/single-spa-react/index.d.ts index 82656bfaf5..9769d41963 100644 --- a/types/single-spa-react/index.d.ts +++ b/types/single-spa-react/index.d.ts @@ -1,29 +1,32 @@ // Type definitions for single-spa-react 2.8 // Project: https://github.com/CanopyTax/single-spa-react // Definitions by: Garrett Smith +// Chris Dopuch // 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; - domElementGetter?: () => Element; - suppressComponentDidCatchWarning?: boolean; - parcelCanUpdate?: boolean; - } + interface Options { + React: typeof React; + ReactDOM: typeof ReactDOM; + rootComponent?: React.ComponentClass; + loadRootComponent?: () => Promise>; + domElementGetter?: () => Element; + suppressComponentDidCatchWarning?: boolean; + parcelCanUpdate?: boolean; + } - interface Lifecycles { - bootstrap: (opts: Options, props: any) => Promise; - mount: (opts: Options, props: any) => Promise; - unmount: (opts: Options, props: any) => Promise; - } + interface Lifecycles { + bootstrap: (props: any) => Promise; + mount: (props: any) => Promise; + unmount: (props: any) => Promise; + } } diff --git a/types/single-spa-react/single-spa-react-tests.ts b/types/single-spa-react/single-spa-react-tests.ts deleted file mode 100644 index 7efed91489..0000000000 --- a/types/single-spa-react/single-spa-react-tests.ts +++ /dev/null @@ -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, -}); diff --git a/types/single-spa-react/single-spa-react-tests.tsx b/types/single-spa-react/single-spa-react-tests.tsx new file mode 100644 index 0000000000..b9350fdb04 --- /dev/null +++ b/types/single-spa-react/single-spa-react-tests.tsx @@ -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 { + render() { + return
hello{this.props.name} !
; + } +} + +// $ExpectType Lifecycles +singleSpaReact({ + React, + ReactDOM, + rootComponent +}); diff --git a/types/single-spa-react/tsconfig.json b/types/single-spa-react/tsconfig.json index 4204827d4d..a2b1f12071 100644 --- a/types/single-spa-react/tsconfig.json +++ b/types/single-spa-react/tsconfig.json @@ -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"] }