[global-modules-path] introduce types (#37246)

This commit is contained in:
Gareth Jones 2019-08-01 09:43:25 +12:00 committed by Jesse Trinity
parent 7923edeecc
commit 2fab8543dd
4 changed files with 55 additions and 0 deletions

View File

@ -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

6
types/global-modules-path/index.d.ts vendored Normal file
View File

@ -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 <https://github.com/g-rath>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function getPath(module: string, executable?: string): string | null;

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }