From 2fab8543ddac8030c8b1fc21f27da135027429bb Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 1 Aug 2019 09:43:25 +1200 Subject: [PATCH] [global-modules-path] introduce types (#37246) --- .../global-modules-path-tests.ts | 25 +++++++++++++++++++ types/global-modules-path/index.d.ts | 6 +++++ types/global-modules-path/tsconfig.json | 23 +++++++++++++++++ types/global-modules-path/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/global-modules-path/global-modules-path-tests.ts create mode 100644 types/global-modules-path/index.d.ts create mode 100644 types/global-modules-path/tsconfig.json create mode 100644 types/global-modules-path/tslint.json diff --git a/types/global-modules-path/global-modules-path-tests.ts b/types/global-modules-path/global-modules-path-tests.ts new file mode 100644 index 0000000000..298a4ff7c2 --- /dev/null +++ b/types/global-modules-path/global-modules-path-tests.ts @@ -0,0 +1,25 @@ +import globalModulesPath = require('global-modules-path'); + +globalModulesPath(); // $ExpectError +globalModulesPath.getPath(); // $ExpectError +globalModulesPath.getPath(undefined, undefined); // $ExpectError +globalModulesPath.getPath(undefined, 'hello'); // $ExpectError + +globalModulesPath.getPath(undefined); // $ExpectError +globalModulesPath.getPath(null); // $ExpectError +globalModulesPath.getPath(() => {}); // $ExpectError +globalModulesPath.getPath({}); // $ExpectError +globalModulesPath.getPath(1); // $ExpectError +globalModulesPath.getPath([]); // $ExpectError +globalModulesPath.getPath(({})); // $ExpectError + +globalModulesPath.getPath('typescript', undefined); // $ExpectType string | null +globalModulesPath.getPath('typescript', null); // $ExpectError +globalModulesPath.getPath('typescript', () => {}); // $ExpectError +globalModulesPath.getPath('typescript', {}); // $ExpectError +globalModulesPath.getPath('typescript', 1); // $ExpectError +globalModulesPath.getPath('typescript', []); // $ExpectError +globalModulesPath.getPath('typescript', ({})); // $ExpectError + +globalModulesPath.getPath('typescript'); // $ExpectType string | null +globalModulesPath.getPath('typescript', 'tsc'); // $ExpectType string | null diff --git a/types/global-modules-path/index.d.ts b/types/global-modules-path/index.d.ts new file mode 100644 index 0000000000..776a485d30 --- /dev/null +++ b/types/global-modules-path/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for global-modules-path 2.3 +// Project: https://www.npmjs.com/package/global-modules-path +// Definitions by: Gareth Jones +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function getPath(module: string, executable?: string): string | null; diff --git a/types/global-modules-path/tsconfig.json b/types/global-modules-path/tsconfig.json new file mode 100644 index 0000000000..c3c9a5d768 --- /dev/null +++ b/types/global-modules-path/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", + "global-modules-path-tests.ts" + ] +} diff --git a/types/global-modules-path/tslint.json b/types/global-modules-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/global-modules-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }