From 8d4dd52d265c6d5c1b536fecc2f02998fc8089a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Tue, 14 Apr 2020 01:21:57 +0200 Subject: [PATCH] feat(globalyzer): new type definition (#43827) - type definition - tests https://github.com/terkelg/globalyzer#api Thanks! --- types/globalyzer/globalyzer-tests.ts | 7 +++++++ types/globalyzer/index.d.ts | 26 ++++++++++++++++++++++++++ types/globalyzer/tsconfig.json | 23 +++++++++++++++++++++++ types/globalyzer/tslint.json | 1 + 4 files changed, 57 insertions(+) create mode 100644 types/globalyzer/globalyzer-tests.ts create mode 100644 types/globalyzer/index.d.ts create mode 100644 types/globalyzer/tsconfig.json create mode 100644 types/globalyzer/tslint.json diff --git a/types/globalyzer/globalyzer-tests.ts b/types/globalyzer/globalyzer-tests.ts new file mode 100644 index 0000000000..f77a394d52 --- /dev/null +++ b/types/globalyzer/globalyzer-tests.ts @@ -0,0 +1,7 @@ +import globalyzer = require('globalyzer'); + +globalyzer('foo/bar/.git/'); // $ExpectType { base: string; glob: string; isGlob: boolean; } +// => { base: 'foo/bar/.git/', glob: '', isGlob: false } + +globalyzer('foo/bar/**/baz'); // $ExpectType { base: string; glob: string; isGlob: boolean; } +// => { base: 'foo/bar', glob: '**/baz', isGlob: true } diff --git a/types/globalyzer/index.d.ts b/types/globalyzer/index.d.ts new file mode 100644 index 0000000000..39d6d8f84c --- /dev/null +++ b/types/globalyzer/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for globalyzer 0.1 +// Project: https://github.com/terkelg/globalyzer#readme +// Definitions by: Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Detect and extract the static part of a glob string. + * Utility to detect if a string contains a glob and then split it in a glob and none-glob part. + * @param pattern - Glob string to analyze + */ +declare function globalyzer( + glob: string, + options?: { + /** + * Use strict parsing (be strict about what's a glob and what's not) + * @default false + */ + strict?: boolean; + }, +): { + base: string; + glob: string; + isGlob: boolean; +}; + +export = globalyzer; diff --git a/types/globalyzer/tsconfig.json b/types/globalyzer/tsconfig.json new file mode 100644 index 0000000000..cf557e17ec --- /dev/null +++ b/types/globalyzer/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", + "globalyzer-tests.ts" + ] +} diff --git a/types/globalyzer/tslint.json b/types/globalyzer/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/globalyzer/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }