From a5544dce7b010603ce9d1f7bdf8f2cb071a65254 Mon Sep 17 00:00:00 2001 From: Garrett Smith Date: Wed, 1 Aug 2018 15:10:15 -0500 Subject: [PATCH] single-spa-react: typings (#27777) * single-spa-react: typings * fix ts version --- types/single-spa-react/index.d.ts | 29 +++++++++++++++++++ .../single-spa-react-tests.ts | 10 +++++++ types/single-spa-react/tsconfig.json | 23 +++++++++++++++ types/single-spa-react/tslint.json | 1 + 4 files changed, 63 insertions(+) create mode 100644 types/single-spa-react/index.d.ts create mode 100644 types/single-spa-react/single-spa-react-tests.ts create mode 100644 types/single-spa-react/tsconfig.json create mode 100644 types/single-spa-react/tslint.json 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" }