diff --git a/types/single-spa-react/index.d.ts b/types/single-spa-react/index.d.ts new file mode 100644 index 0000000000..67721695ec --- /dev/null +++ b/types/single-spa-react/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for single-spa-react 2.8 +// Project: https://github.com/CanopyTax/single-spa-react +// Definitions by: Garrett Smith +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; + +export = SingleSpaReact; +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 Lifecycles { + bootstrap: (opts: Options, props: any) => Promise; + mount: (opts: Options, props: any) => Promise; + unmount: (opts: Options, 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 new file mode 100644 index 0000000000..7efed91489 --- /dev/null +++ b/types/single-spa-react/single-spa-react-tests.ts @@ -0,0 +1,10 @@ +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/tsconfig.json b/types/single-spa-react/tsconfig.json new file mode 100644 index 0000000000..3ccb45cf0c --- /dev/null +++ b/types/single-spa-react/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "single-spa-react-tests.ts" + ] +} diff --git a/types/single-spa-react/tslint.json b/types/single-spa-react/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/single-spa-react/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }