diff --git a/types/original/index.d.ts b/types/original/index.d.ts new file mode 100644 index 0000000000..b726393ef3 --- /dev/null +++ b/types/original/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for original 1.0 +// 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. + * + * @param url URL to transform to it's origin. + * @returns The origin. + * @api public + */ +declare function origin(url: string | object | { protocol: string, host: string }): 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..d88586e5bd --- /dev/null +++ b/types/original/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}