From e62e3a8e64ffa533bce1087292855e5fcc519680 Mon Sep 17 00:00:00 2001 From: Wayne Carson Date: Sun, 16 Dec 2018 11:58:54 -0800 Subject: [PATCH 1/3] Added typings for original (https://github.com/unshiftio/original) --- types/original/index.d.ts | 27 +++++++++++++++++++++++++++ types/original/original-tests.ts | 7 +++++++ types/original/tsconfig.json | 23 +++++++++++++++++++++++ types/original/tslint.json | 6 ++++++ 4 files changed, 63 insertions(+) create mode 100644 types/original/index.d.ts create mode 100644 types/original/original-tests.ts create mode 100644 types/original/tsconfig.json create mode 100644 types/original/tslint.json diff --git a/types/original/index.d.ts b/types/original/index.d.ts new file mode 100644 index 0000000000..04a00bd2f1 --- /dev/null +++ b/types/original/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for debounce 1.0 +// Project: https://github.com/unshiftio/original +// Definitions by: Wayne Carson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Transform an URL to a valid origin value. + * + * @param url URL to transform to it's origin. + * @returns The origin. + * @api public + */ +declare function origin(url: string|Object): string; + +declare namespace origin { + /** + * Check if the origins are the same. + * + * @param a URL or origin of a. + * @param b URL or origin of b. + * @returns true if origins are the same, false otherwise + * @api public + */ + function same(a: string, b: string): boolean; +} + +export = origin; diff --git a/types/original/original-tests.ts b/types/original/original-tests.ts new file mode 100644 index 0000000000..a7d0a865be --- /dev/null +++ b/types/original/original-tests.ts @@ -0,0 +1,7 @@ +import origin = require('original'); + +// $ExpectType string +origin('https://google.com/gmail'); + +// $ExpectType boolean +origin.same('https://google.com/gmail', 'https://google.com:443/gmail'); diff --git a/types/original/tsconfig.json b/types/original/tsconfig.json new file mode 100644 index 0000000000..e80b892467 --- /dev/null +++ b/types/original/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "original-tests.ts" + ] +} diff --git a/types/original/tslint.json b/types/original/tslint.json new file mode 100644 index 0000000000..5bc412fb1e --- /dev/null +++ b/types/original/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "ban-types": false + } +} From dbc1a0c9866f2cfb5482f1f314983a2f35ceb112 Mon Sep 17 00:00:00 2001 From: Wayne Carson Date: Sun, 16 Dec 2018 12:06:05 -0800 Subject: [PATCH 2/3] Fixed typo in index.d.ts (original) --- types/original/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/original/index.d.ts b/types/original/index.d.ts index 04a00bd2f1..dee708ccb7 100644 --- a/types/original/index.d.ts +++ b/types/original/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for debounce 1.0 +// Type definitions for original 1.0 // Project: https://github.com/unshiftio/original // Definitions by: Wayne Carson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 33dbaed80d83d85083061a8644870ea766c17752 Mon Sep 17 00:00:00 2001 From: Wayne Carson Date: Mon, 17 Dec 2018 19:36:38 -0800 Subject: [PATCH 3/3] [original] Updated constructor params to have more specific types per review suggestion --- types/original/index.d.ts | 3 ++- types/original/tslint.json | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/types/original/index.d.ts b/types/original/index.d.ts index dee708ccb7..b726393ef3 100644 --- a/types/original/index.d.ts +++ b/types/original/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/unshiftio/original // Definitions by: Wayne Carson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /** * Transform an URL to a valid origin value. @@ -10,7 +11,7 @@ * @returns The origin. * @api public */ -declare function origin(url: string|Object): string; +declare function origin(url: string | object | { protocol: string, host: string }): string; declare namespace origin { /** diff --git a/types/original/tslint.json b/types/original/tslint.json index 5bc412fb1e..d88586e5bd 100644 --- a/types/original/tslint.json +++ b/types/original/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "ban-types": false - } + "extends": "dtslint/dt.json" }