diff --git a/types/react-global-configuration/index.d.ts b/types/react-global-configuration/index.d.ts new file mode 100644 index 0000000000..30ce772f10 --- /dev/null +++ b/types/react-global-configuration/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for react-global-configuration 1.3 +// Project: https://github.com/morenofa/react-global-configuration#readme +// Definitions by: Ryo Kikuchi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export interface Options { + freeze: boolean; + assign: boolean; +} + +declare namespace ReactGlobalConfiguration { + function set(newConfiguration: any, newOptions?: Options): void; + function get(key?: string): any; + function get(key: string, fallbackValue: Value): Value; + function serialize(): string; +} + +export default ReactGlobalConfiguration; diff --git a/types/react-global-configuration/react-global-configuration-tests.ts b/types/react-global-configuration/react-global-configuration-tests.ts new file mode 100644 index 0000000000..05cd15f95d --- /dev/null +++ b/types/react-global-configuration/react-global-configuration-tests.ts @@ -0,0 +1,25 @@ +import config from "react-global-configuration"; + +interface UserConfig { + a: number; + b: string; + c: { + ca: 123; + cb: 'ABC'; + }; +} + +config.set({ + a: 456, + b: "DEF", + c: { + ca: 123, + cb: 'ABC', + } +}); + +config.serialize(); + +const all = config.get(); // all: any +const a = config.get('a', 789); // a: number +const d = config.get('d'); // d: any diff --git a/types/react-global-configuration/tsconfig.json b/types/react-global-configuration/tsconfig.json new file mode 100644 index 0000000000..d55b74d8f8 --- /dev/null +++ b/types/react-global-configuration/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-global-configuration-tests.ts" + ] +} diff --git a/types/react-global-configuration/tslint.json b/types/react-global-configuration/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-global-configuration/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }