From b1ca3864162b5f3ea4625a75f7798368b4d269a4 Mon Sep 17 00:00:00 2001 From: Florian Keller Date: Wed, 22 May 2019 18:07:08 +0200 Subject: [PATCH] Add types for multiple vigour.io projects (#35629) Included projects: * is-number-like * quick-hash * turbostatus * vigour-ua --- types/is-number-like/index.d.ts | 13 ++++++++ types/is-number-like/is-number-like-tests.ts | 4 +++ types/is-number-like/tsconfig.json | 23 +++++++++++++++ types/is-number-like/tslint.json | 1 + types/quick-hash/index.d.ts | 13 ++++++++ types/quick-hash/quick-hash-tests.ts | 3 ++ types/quick-hash/tsconfig.json | 23 +++++++++++++++ types/quick-hash/tslint.json | 1 + types/turbostatus/index.d.ts | 31 ++++++++++++++++++++ types/turbostatus/tsconfig.json | 23 +++++++++++++++ types/turbostatus/tslint.json | 1 + types/turbostatus/turbostatus-tests.ts | 5 ++++ types/vigour-ua/index.d.ts | 30 +++++++++++++++++++ types/vigour-ua/tsconfig.json | 23 +++++++++++++++ types/vigour-ua/tslint.json | 1 + types/vigour-ua/vigour-ua-tests.ts | 11 +++++++ 16 files changed, 206 insertions(+) create mode 100644 types/is-number-like/index.d.ts create mode 100644 types/is-number-like/is-number-like-tests.ts create mode 100644 types/is-number-like/tsconfig.json create mode 100644 types/is-number-like/tslint.json create mode 100644 types/quick-hash/index.d.ts create mode 100644 types/quick-hash/quick-hash-tests.ts create mode 100644 types/quick-hash/tsconfig.json create mode 100644 types/quick-hash/tslint.json create mode 100644 types/turbostatus/index.d.ts create mode 100644 types/turbostatus/tsconfig.json create mode 100644 types/turbostatus/tslint.json create mode 100644 types/turbostatus/turbostatus-tests.ts create mode 100644 types/vigour-ua/index.d.ts create mode 100644 types/vigour-ua/tsconfig.json create mode 100644 types/vigour-ua/tslint.json create mode 100644 types/vigour-ua/vigour-ua-tests.ts diff --git a/types/is-number-like/index.d.ts b/types/is-number-like/index.d.ts new file mode 100644 index 0000000000..f9eabebf52 --- /dev/null +++ b/types/is-number-like/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for is-number-like 1.0 +// Project: https://github.com/vigour-io/is-number-like#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Checks whether provided parameter looks like a number + * @param val the value to check + * @returns `true` if `val` looks like a number, `false` otherwise + */ +declare function isNumberLike(val: any): boolean; + +export = isNumberLike; diff --git a/types/is-number-like/is-number-like-tests.ts b/types/is-number-like/is-number-like-tests.ts new file mode 100644 index 0000000000..977bd07d66 --- /dev/null +++ b/types/is-number-like/is-number-like-tests.ts @@ -0,0 +1,4 @@ +import isNumberLike = require('is-number-like'); + +isNumberLike('2'); // $ExpectType boolean +isNumberLike('a'); // $ExpectType boolean diff --git a/types/is-number-like/tsconfig.json b/types/is-number-like/tsconfig.json new file mode 100644 index 0000000000..c0bfbd126e --- /dev/null +++ b/types/is-number-like/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", + "is-number-like-tests.ts" + ] +} diff --git a/types/is-number-like/tslint.json b/types/is-number-like/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-number-like/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/quick-hash/index.d.ts b/types/quick-hash/index.d.ts new file mode 100644 index 0000000000..1a6babb23e --- /dev/null +++ b/types/quick-hash/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for quick-hash 1.0 +// Project: https://github.com/vigour-io/quick-hash#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Murmur hash optimized for performance, not collision avoidance. + * @param key the string to hash + * @param seed a seed for hashing + * @returns A string of 5 to 7 alpha-numeric characters + */ +declare function quickHash(key: string, seed?: number): string; +export = quickHash; diff --git a/types/quick-hash/quick-hash-tests.ts b/types/quick-hash/quick-hash-tests.ts new file mode 100644 index 0000000000..0ea740620b --- /dev/null +++ b/types/quick-hash/quick-hash-tests.ts @@ -0,0 +1,3 @@ +import hash = require('quick-hash'); +hash('Any string'); // $ExpectType string +hash('Another string', 100); // $ExpectType string diff --git a/types/quick-hash/tsconfig.json b/types/quick-hash/tsconfig.json new file mode 100644 index 0000000000..c245c480dc --- /dev/null +++ b/types/quick-hash/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", + "quick-hash-tests.ts" + ] +} diff --git a/types/quick-hash/tslint.json b/types/quick-hash/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/quick-hash/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/turbostatus/index.d.ts b/types/turbostatus/index.d.ts new file mode 100644 index 0000000000..9f7fdfe992 --- /dev/null +++ b/types/turbostatus/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for turbostatus 2.4 +// Project: https://github.com/vigour-io/turbostatus#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Repository { + name: string; + path: string; +} + +export interface Description { + commitsSinceTag: string | false; + hash: string; + nearestTag: string | false; +} + +export function checkout(folder: string, commit: string): Promise; +export function clone(origin: string, folder: string): Promise; +export function describe(folder: string): Promise; +export function getBranch(folder: string): Promise; +export function getBranchFast(folder: string): Promise; +export function getLocalCommit(folder: string): Promise; +export function getMergeBase(folder: string): Promise; +export function getOrigin(folder: string): Promise; +export function getRemoteCommit(folder: string): Promise; +export function getRepos(folder: string, wildcard?: string): Promise; +export function hasUncommited(folder: string): Promise; +export function hasUntracked(folder: string): Promise; +export function info(repo: Repository, remotes?: boolean): Promise; +export function isRepo(folder: string): Promise; +export function references(folder: string): Promise; diff --git a/types/turbostatus/tsconfig.json b/types/turbostatus/tsconfig.json new file mode 100644 index 0000000000..4fcd2d61b2 --- /dev/null +++ b/types/turbostatus/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", + "turbostatus-tests.ts" + ] +} diff --git a/types/turbostatus/tslint.json b/types/turbostatus/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/turbostatus/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/turbostatus/turbostatus-tests.ts b/types/turbostatus/turbostatus-tests.ts new file mode 100644 index 0000000000..1d97f09e0a --- /dev/null +++ b/types/turbostatus/turbostatus-tests.ts @@ -0,0 +1,5 @@ +import * as turbostatus from 'turbostatus'; + +turbostatus.checkout('./', 'master'); +turbostatus.isRepo('./'); +turbostatus.describe('./'); diff --git a/types/vigour-ua/index.d.ts b/types/vigour-ua/index.d.ts new file mode 100644 index 0000000000..a9c56a70db --- /dev/null +++ b/types/vigour-ua/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for vigour-ua 4.0 +// Project: https://github.com/vigour-io/ua#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +declare namespace ua { + interface UserAgent { + [value: string]: string | number; + browser: string; + prefix: string; + version: number; + } +} + +/** + * Returns an object representing the user agent including data such as browser, device and platform + * @param _ua the raw user agent string to be converted + * @param obj object to be merged to the output result + * @returns object representing your user agent + */ +declare function ua(_ua: string): ua.UserAgent; +/** + * Returns an object representing the user agent including data such as browser, device and platform + * @param _ua the raw user agent string to be converted + * @returns object representing your user agent + */ +declare function ua(_ua: string, obj: T): ua.UserAgent & T; + +export = ua; diff --git a/types/vigour-ua/tsconfig.json b/types/vigour-ua/tsconfig.json new file mode 100644 index 0000000000..ef93350bae --- /dev/null +++ b/types/vigour-ua/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", + "vigour-ua-tests.ts" + ] +} diff --git a/types/vigour-ua/tslint.json b/types/vigour-ua/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vigour-ua/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vigour-ua/vigour-ua-tests.ts b/types/vigour-ua/vigour-ua-tests.ts new file mode 100644 index 0000000000..48577db400 --- /dev/null +++ b/types/vigour-ua/vigour-ua-tests.ts @@ -0,0 +1,11 @@ +import ua = require('vigour-ua'); + +const userAgent = + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.3'; + +const someObject = { + randomField: true, +}; + +ua(userAgent, someObject); +ua(userAgent);