From a2510a9e90109329524564b20fbc08e0997a001c Mon Sep 17 00:00:00 2001 From: Christopher Woodland Date: Mon, 26 Feb 2018 21:40:45 -0500 Subject: [PATCH 1/6] Move firsby definition for 0.8.5 to its own version folder. Add typings for v2.0 of frisby.js --- types/frisby/frisby-tests.ts | 44 ++-- types/frisby/index.d.ts | 437 +++++++++++++++++++++++++++----- types/frisby/tsconfig.json | 17 +- types/frisby/tslint.json | 78 +----- types/frisby/v0/frisby-tests.ts | 26 ++ types/frisby/v0/index.d.ts | 75 ++++++ types/frisby/v0/tsconfig.json | 29 +++ types/frisby/v0/tslint.json | 79 ++++++ 8 files changed, 609 insertions(+), 176 deletions(-) create mode 100644 types/frisby/v0/frisby-tests.ts create mode 100644 types/frisby/v0/index.d.ts create mode 100644 types/frisby/v0/tsconfig.json create mode 100644 types/frisby/v0/tslint.json diff --git a/types/frisby/frisby-tests.ts b/types/frisby/frisby-tests.ts index d5ac312b83..d0bb27ff20 100644 --- a/types/frisby/frisby-tests.ts +++ b/types/frisby/frisby-tests.ts @@ -1,27 +1,21 @@ -//Example from https://www.npmjs.com/package/frisby +import * as frisby from 'frisby'; -import frisby = require('frisby'); - -var URL = 'http://localhost:3000/'; -var URL_AUTH = 'http://username:password@localhost:3000/'; - -frisby.globalSetup({ // globalSetup is for ALL requests - request: { - headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' } - } +frisby.globalSetup({ + request: { + headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' } + } +}); + +describe('Test Suite 1', () => { + it('should be a teapot get', (done) => { + frisby.get(URL + '/users/3.json') + .expect('status', 418) + .done(done); + }); + + it('should be a teapot post', (done) => { + frisby.post(URL + '/users/3.json') + .expect('status', 418) + .done(done); + }); }); - -frisby.create('GET user johndoe') - .get(URL + '/users/3.json') - .expectStatus(200) - .expectJSONTypes({ - id: Number, - username: String, - is_admin: Boolean - }) - .expectJSON({ - id: 3, - username: 'johndoe', - is_admin: false - }) -.toss(); \ No newline at end of file diff --git a/types/frisby/index.d.ts b/types/frisby/index.d.ts index 523c72e6db..b3a84c28a0 100644 --- a/types/frisby/index.d.ts +++ b/types/frisby/index.d.ts @@ -1,75 +1,386 @@ -// Type definitions for Frisby v0.8.5 +// Type definitions for Frisby 2.0 // Project: https://github.com/vlucas/frisby -// Definitions by: Johnny Li +// Definitions by: Christopher E. Woodland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.6 -/// +/// -declare interface Frisby { - globalSetup(opts: any): any; - timeout(seconds?: number): Frisby; - reset(): Frisby; - not(): Frisby; - addHeader(key: string, content: string): Frisby; - addHeaders(headers: object): Frisby; - removeHeader(key: string): Frisby; - responseType(type: any): Frisby; - // HTTP Basic Auth - auth(username: string, password: string, digest: boolean): Frisby; - // HTTP Request - get(uri: string, params?: any): Frisby; - patch(uri: string, data?: any, params?: any): Frisby; - post(uri: string, data?: any, params?: any): Frisby; - put(uri: string, data?: any, params?: any): Frisby; - delete(uri: string, data?: any, params?: any): Frisby; - head(uri: string, params?: any): Frisby; - options(uri: string, params?: any): Frisby; +// #region Imports +import { Response } from 'node-fetch'; // Import all definitions from node-fetch. +//#endregion - expectMaxResponseTime(milliseconds: number): Frisby; - expectStatus(statusCode: number): Frisby; - expectHeader(header: string, content: string): Frisby; - expectHeaderContains(header: string, content: string): Frisby; - expectHeaderToMatch(header: string, pattern: RegExp): Frisby; - expectBodyContains(content: string): Frisby; - expectJSONTypes(json: any): Frisby; - expectJSONTypes(path: string, json: any): Frisby; - expectJSON(json: any): Frisby; - expectJSON(path: string, json: any): Frisby; - expectJSONSchema(path: string, jsonSchema: any): Frisby; - expectJSONLength(length: number): Frisby; - expectJSONLength(path: string, length: number): Frisby; - inspectRequest(): Frisby; - inspectResponse(): Frisby; - inspectHeaders(): Frisby; - inspectBody(): Frisby; - inspectJSON(): Frisby; - inspectStatus(): Frisby; - retry(count: number, delayInMilliseconds?: number): Frisby; - waits(delayInMilliseconds: number): Frisby; - after(callback: (...args: any[]) => void): Frisby; - afterJSON(callback: (...args: any[]) => void): Frisby; - exceptionHandler(fn: (...args: any[]) => void): Frisby; - toss(): void; +// #region Joi Methods +// Reference file: https://github.com/hapijs/joi +export namespace Joi { + const isImmutable: boolean; - create(msg: string): Frisby; + const isJoi: boolean; -} + const schemaType: string; -declare global { - namespace jasmine { - interface Matchers { - toMatchOrBeNull(expected: any): boolean; - toMatchOrBeEmpty(expected: any): boolean; - toBeType(expected: any): boolean; - toBeTypeOrNull(expected: any): boolean; - toBeTypeOrUndefined(expected: any): boolean; - toContainJson(expected: any, isNot?: boolean): boolean; - toContainJsonTypes(expected: any, isNot?: boolean): boolean; - } + const version: string; + + function allow(...args: any[]): void; + + function alt(args: any): any; + + function alternatives(args: any): any; + + function any(args: any): any; + + function applyFunctionToChildren(...args: any[]): void; + + function array(args: any): any; + + function assert(value: any, schema: any, message: string): void; + + function attempt(value: any, schema: any, message: string): any; + + function binary(args: any): any; + + function bool(args: any): any; + + function checkOptions(...args: any[]): void; + + function clone(...args: any[]): void; + + function compile(schema: any): any; + + function concat(...args: any[]): void; + + function createError(...args: any[]): void; + + function createOverrideError(...args: any[]): void; + + function date(args: any): any; + + function defaults(fn: any): any; + + function describe(args: any): any; + + function description(...args: any[]): void; + + function disallow(...args: any[]): void; + + function empty(...args: any[]): void; + + function equal(...args: any[]): void; + + function error(...args: any[]): void; + + function example(...args: any[]): void; + + function exist(...args: any[]): void; + + function extend(args: any): any; + + function forbidden(...args: any[]): void; + + function func(args: any): any; + + function invalid(...args: any[]): void; + + function isRef(ref: any): any; + + function label(...args: any[]): void; + + function lazy(fn: any): any; + + function meta(...args: any[]): void; + + function not(...args: any[]): void; + + function notes(...args: any[]): void; + + function number(args: any): any; + + function object(args: any): any; + + function only(...args: any[]): void; + + function optional(...args: any[]): void; + + function options(...args: any[]): void; + + function raw(...args: any[]): void; + + function reach(schema: any, path: any): any; + + function ref(args: any): any; + + function required(...args: any[]): void; + + function strict(...args: any[]): void; + + function string(args: any): any; + + function strip(...args: any[]): void; + + function tags(...args: any[]): void; + + function unit(...args: any[]): void; + + function valid(...args: any[]): void; + + function validate(value: any, args: any): any; + + function when(...args: any[]): void; + + namespace extensionSchema { + const isImmutable: boolean; + + const isJoi: boolean; + + const schemaType: string; + + function allow(...args: any[]): void; + + function and(...args: any[]): void; + + function applyFunctionToChildren(...args: any[]): void; + + function assert(...args: any[]): void; + + function checkOptions(...args: any[]): void; + + function clone(...args: any[]): void; + + function concat(...args: any[]): void; + + function createError(...args: any[]): void; + + function createOverrideError(...args: any[]): void; + + function describe(...args: any[]): void; + + function description(...args: any[]): void; + + function disallow(...args: any[]): void; + + function empty(...args: any[]): void; + + function equal(...args: any[]): void; + + function error(...args: any[]): void; + + function example(...args: any[]): void; + + function exist(...args: any[]): void; + + function forbidden(...args: any[]): void; + + function forbiddenKeys(...args: any[]): void; + + function invalid(...args: any[]): void; + + function keys(...args: any[]): void; + + function label(...args: any[]): void; + + function length(...args: any[]): void; + + function max(...args: any[]): void; + + function meta(...args: any[]): void; + + function min(...args: any[]): void; + + function nand(...args: any[]): void; + + function not(...args: any[]): void; + + function notes(...args: any[]): void; + + function only(...args: any[]): void; + + function optional(...args: any[]): void; + + function optionalKeys(...args: any[]): void; + + function options(...args: any[]): void; + + function or(...args: any[]): void; + + function pattern(...args: any[]): void; + + function raw(...args: any[]): void; + + function rename(...args: any[]): void; + + function required(...args: any[]): void; + + function requiredKeys(...args: any[]): void; + + function schema(...args: any[]): void; + + function strict(...args: any[]): void; + + function strip(...args: any[]): void; + + function tags(...args: any[]): void; + + function type(...args: any[]): void; + + function unit(...args: any[]): void; + + function unknown(...args: any[]): void; + + function valid(...args: any[]): void; + + function validate(...args: any[]): void; + + function when(...args: any[]): void; + + function without(...args: any[]): void; + + function xor(...args: any[]): void; + } + + namespace extensionsSchema { + const isImmutable: boolean; + + const isJoi: boolean; + + const schemaType: string; + + function allow(...args: any[]): void; + + function applyFunctionToChildren(...args: any[]): void; + + function checkOptions(...args: any[]): void; + + function clone(...args: any[]): void; + + function concat(...args: any[]): void; + + function createError(...args: any[]): void; + + function createOverrideError(...args: any[]): void; + + function describe(...args: any[]): void; + + function description(...args: any[]): void; + + function disallow(...args: any[]): void; + + function empty(...args: any[]): void; + + function equal(...args: any[]): void; + + function error(...args: any[]): void; + + function example(...args: any[]): void; + + function exist(...args: any[]): void; + + function forbidden(...args: any[]): void; + + function invalid(...args: any[]): void; + + function items(...args: any[]): void; + + function label(...args: any[]): void; + + function length(...args: any[]): void; + + function max(...args: any[]): void; + + function meta(...args: any[]): void; + + function min(...args: any[]): void; + + function not(...args: any[]): void; + + function notes(...args: any[]): void; + + function only(...args: any[]): void; + + function optional(...args: any[]): void; + + function options(...args: any[]): void; + + function ordered(...args: any[]): void; + + function raw(...args: any[]): void; + + function required(...args: any[]): void; + + function single(...args: any[]): void; + + function sparse(...args: any[]): void; + + function strict(...args: any[]): void; + + function strip(...args: any[]): void; + + function tags(...args: any[]): void; + + function unique(...args: any[]): void; + + function unit(...args: any[]): void; + + function valid(...args: any[]): void; + + function validate(...args: any[]): void; + + function when(...args: any[]): void; } } +// #endregion -declare const frisby: Frisby; -export = frisby; +// #region Frisby FrisbySpec Methods +// Reference file: https://github.com/vlucas/frisby/blob/master/src/frisby/spec.js +export class FrisbySpec { + constructor(...args: any[]); + catch(onRejected?: (error: Error) => void): FrisbySpec; + del(url: string, params: {}): FrisbySpec; + done(doneFn: (...args: any[]) => void): FrisbySpec; + expect(expectName: string, ...args: any[]): FrisbySpec; + expectNot(expectName: string): FrisbySpec; + fetch(url: string, params: {}, options?: {}): FrisbySpec; + fromJSON(json: {}): FrisbySpec; + get(url: string, params: {}): FrisbySpec; + getBaseUrl(): string | boolean; + inspectBody(): FrisbySpec; + inspectHeaders(): FrisbySpec; + inspectJSON(): FrisbySpec; + inspectLog(...args: any[]): FrisbySpec; + inspectRequest(): FrisbySpec; + inspectRequestHeaders(): FrisbySpec; + inspectResponse(): FrisbySpec; + inspectStatus(): FrisbySpec; + patch(url: string, params: {}): FrisbySpec; + post(url: string, params: {}): FrisbySpec; + promise(): Promise; + put(url: string, params: {}): FrisbySpec; + setup(opts: {}, replace: boolean): FrisbySpec; + then(onFulfilled: {} | ((...args: any[]) => void), onRejected: (...args: any[]) => void): FrisbySpec; + timeout(timeout: number): number; + use(fn: (...args: any[]) => void): FrisbySpec; + static addExpectHandler(expectName: string, expectFn: (...args: any[]) => any): void; + static removeExpectHandler(expectName: string): void; +} +// #endregion +// #region General Frisby Methods +// Reference file: https://github.com/vlucas/frisby/blob/master/src/frisby.js + +export const version: string; +export function addExpectHandler(expectName: string, expectFn: (...args: any[]) => any): FrisbySpec; +export function baseUrl(url: string): void; +export function create(name: string): void; +export function del(...args: any[]): FrisbySpec; +export function fetch(...args: any[]): FrisbySpec; +export function formData(): FormData; +export function fromJSON(...args: any[]): FrisbySpec; +export function get(...args: any[]): FrisbySpec; +export function globalSetup(opts: {}): void; +export function patch(...args: any[]): FrisbySpec; +export function post(...args: any[]): FrisbySpec; +export function put(...args: any[]): FrisbySpec; +export function removeExpectHandler(expectName: string, expectFn: (...args: any[]) => any): FrisbySpec; +export function setup(...args: any[]): FrisbySpec; +export function timeout(...args: any[]): FrisbySpec; +export function use(...args: any[]): FrisbySpec; +// #endregion diff --git a/types/frisby/tsconfig.json b/types/frisby/tsconfig.json index 725ebf48f1..b5780edd98 100644 --- a/types/frisby/tsconfig.json +++ b/types/frisby/tsconfig.json @@ -1,24 +1,19 @@ { "compilerOptions": { + "baseUrl": "../", + "forceConsistentCasingInFileNames": true, + "lib": ["es6","dom"], "module": "commonjs", - "lib": [ - "es6", - "dom" - ], + "noEmit": true, "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true + "typeRoots": ["../"] }, "files": [ "index.d.ts", "frisby-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/frisby/tslint.json b/types/frisby/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/frisby/tslint.json +++ b/types/frisby/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/frisby/v0/frisby-tests.ts b/types/frisby/v0/frisby-tests.ts new file mode 100644 index 0000000000..f954ddc04e --- /dev/null +++ b/types/frisby/v0/frisby-tests.ts @@ -0,0 +1,26 @@ +//Example from https://www.npmjs.com/package/frisby +import frisby = require('frisby'); + +var URL = 'http://localhost:3000/'; +var URL_AUTH = 'http://username:password@localhost:3000/'; + +frisby.globalSetup({ // globalSetup is for ALL requests + request: { + headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' } + } +}); + +frisby.create('GET user johndoe') + .get(URL + '/users/3.json') + .expectStatus(200) + .expectJSONTypes({ + id: Number, + username: String, + is_admin: Boolean + }) + .expectJSON({ + id: 3, + username: 'johndoe', + is_admin: false + }) +.toss(); diff --git a/types/frisby/v0/index.d.ts b/types/frisby/v0/index.d.ts new file mode 100644 index 0000000000..523c72e6db --- /dev/null +++ b/types/frisby/v0/index.d.ts @@ -0,0 +1,75 @@ +// Type definitions for Frisby v0.8.5 +// Project: https://github.com/vlucas/frisby +// Definitions by: Johnny Li +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +declare interface Frisby { + globalSetup(opts: any): any; + timeout(seconds?: number): Frisby; + reset(): Frisby; + not(): Frisby; + addHeader(key: string, content: string): Frisby; + addHeaders(headers: object): Frisby; + removeHeader(key: string): Frisby; + responseType(type: any): Frisby; + // HTTP Basic Auth + auth(username: string, password: string, digest: boolean): Frisby; + // HTTP Request + get(uri: string, params?: any): Frisby; + patch(uri: string, data?: any, params?: any): Frisby; + post(uri: string, data?: any, params?: any): Frisby; + put(uri: string, data?: any, params?: any): Frisby; + delete(uri: string, data?: any, params?: any): Frisby; + head(uri: string, params?: any): Frisby; + options(uri: string, params?: any): Frisby; + + expectMaxResponseTime(milliseconds: number): Frisby; + expectStatus(statusCode: number): Frisby; + expectHeader(header: string, content: string): Frisby; + expectHeaderContains(header: string, content: string): Frisby; + expectHeaderToMatch(header: string, pattern: RegExp): Frisby; + expectBodyContains(content: string): Frisby; + expectJSONTypes(json: any): Frisby; + expectJSONTypes(path: string, json: any): Frisby; + expectJSON(json: any): Frisby; + expectJSON(path: string, json: any): Frisby; + expectJSONSchema(path: string, jsonSchema: any): Frisby; + expectJSONLength(length: number): Frisby; + expectJSONLength(path: string, length: number): Frisby; + inspectRequest(): Frisby; + inspectResponse(): Frisby; + inspectHeaders(): Frisby; + inspectBody(): Frisby; + inspectJSON(): Frisby; + inspectStatus(): Frisby; + retry(count: number, delayInMilliseconds?: number): Frisby; + waits(delayInMilliseconds: number): Frisby; + after(callback: (...args: any[]) => void): Frisby; + afterJSON(callback: (...args: any[]) => void): Frisby; + exceptionHandler(fn: (...args: any[]) => void): Frisby; + toss(): void; + + create(msg: string): Frisby; + +} + +declare global { + namespace jasmine { + interface Matchers { + toMatchOrBeNull(expected: any): boolean; + toMatchOrBeEmpty(expected: any): boolean; + toBeType(expected: any): boolean; + toBeTypeOrNull(expected: any): boolean; + toBeTypeOrUndefined(expected: any): boolean; + toContainJson(expected: any, isNot?: boolean): boolean; + toContainJsonTypes(expected: any, isNot?: boolean): boolean; + } + } +} + +declare const frisby: Frisby; +export = frisby; + diff --git a/types/frisby/v0/tsconfig.json b/types/frisby/v0/tsconfig.json new file mode 100644 index 0000000000..532da8d7c4 --- /dev/null +++ b/types/frisby/v0/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "baseUrl": "../../", + "forceConsistentCasingInFileNames": true, + "lib": [ + "es6", + "dom" + ], + "module": "commonjs", + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "paths": { + "frisby": [ + "frisby/v0" + ] + }, + "strictNullChecks": false, + "strictFunctionTypes": true, + "types": [], + "typeRoots": [ + "../../" + ] + }, + "files": [ + "index.d.ts", + "frisby-tests.ts" + ] +} diff --git a/types/frisby/v0/tslint.json b/types/frisby/v0/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/frisby/v0/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From ac6469fbcc6d9599d3ec8c3535f11672655442c6 Mon Sep 17 00:00:00 2001 From: Christopher Woodland Date: Mon, 26 Feb 2018 21:43:49 -0500 Subject: [PATCH 2/6] strictNullChecks true --- types/frisby/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/frisby/tsconfig.json b/types/frisby/tsconfig.json index b5780edd98..e07143dad2 100644 --- a/types/frisby/tsconfig.json +++ b/types/frisby/tsconfig.json @@ -7,7 +7,7 @@ "noEmit": true, "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "types": [], "typeRoots": ["../"] From f014d236f892ba946e2442a9687e6f5c7f97f0b0 Mon Sep 17 00:00:00 2001 From: Christopher Woodland Date: Mon, 26 Feb 2018 22:40:13 -0500 Subject: [PATCH 3/6] spacing --- types/frisby/index.d.ts | 152 ---------------------------------------- 1 file changed, 152 deletions(-) diff --git a/types/frisby/index.d.ts b/types/frisby/index.d.ts index b3a84c28a0..899e45ef5e 100644 --- a/types/frisby/index.d.ts +++ b/types/frisby/index.d.ts @@ -14,316 +14,164 @@ import { Response } from 'node-fetch'; // Import all definitions from node-fetch // Reference file: https://github.com/hapijs/joi export namespace Joi { const isImmutable: boolean; - const isJoi: boolean; - const schemaType: string; - const version: string; - function allow(...args: any[]): void; - function alt(args: any): any; - function alternatives(args: any): any; - function any(args: any): any; - function applyFunctionToChildren(...args: any[]): void; - function array(args: any): any; - function assert(value: any, schema: any, message: string): void; - function attempt(value: any, schema: any, message: string): any; - function binary(args: any): any; - function bool(args: any): any; - function checkOptions(...args: any[]): void; - function clone(...args: any[]): void; - function compile(schema: any): any; - function concat(...args: any[]): void; - function createError(...args: any[]): void; - function createOverrideError(...args: any[]): void; - function date(args: any): any; - function defaults(fn: any): any; - function describe(args: any): any; - function description(...args: any[]): void; - function disallow(...args: any[]): void; - function empty(...args: any[]): void; - function equal(...args: any[]): void; - function error(...args: any[]): void; - function example(...args: any[]): void; - function exist(...args: any[]): void; - function extend(args: any): any; - function forbidden(...args: any[]): void; - function func(args: any): any; - function invalid(...args: any[]): void; - function isRef(ref: any): any; - function label(...args: any[]): void; - function lazy(fn: any): any; - function meta(...args: any[]): void; - function not(...args: any[]): void; - function notes(...args: any[]): void; - function number(args: any): any; - function object(args: any): any; - function only(...args: any[]): void; - function optional(...args: any[]): void; - function options(...args: any[]): void; - function raw(...args: any[]): void; - function reach(schema: any, path: any): any; - function ref(args: any): any; - function required(...args: any[]): void; - function strict(...args: any[]): void; - function string(args: any): any; - function strip(...args: any[]): void; - function tags(...args: any[]): void; - function unit(...args: any[]): void; - function valid(...args: any[]): void; - function validate(value: any, args: any): any; - function when(...args: any[]): void; namespace extensionSchema { const isImmutable: boolean; - const isJoi: boolean; - const schemaType: string; - function allow(...args: any[]): void; - function and(...args: any[]): void; - function applyFunctionToChildren(...args: any[]): void; - function assert(...args: any[]): void; - function checkOptions(...args: any[]): void; - function clone(...args: any[]): void; - function concat(...args: any[]): void; - function createError(...args: any[]): void; - function createOverrideError(...args: any[]): void; - function describe(...args: any[]): void; - function description(...args: any[]): void; - function disallow(...args: any[]): void; - function empty(...args: any[]): void; - function equal(...args: any[]): void; - function error(...args: any[]): void; - function example(...args: any[]): void; - function exist(...args: any[]): void; - function forbidden(...args: any[]): void; - function forbiddenKeys(...args: any[]): void; - function invalid(...args: any[]): void; - function keys(...args: any[]): void; - function label(...args: any[]): void; - function length(...args: any[]): void; - function max(...args: any[]): void; - function meta(...args: any[]): void; - function min(...args: any[]): void; - function nand(...args: any[]): void; - function not(...args: any[]): void; - function notes(...args: any[]): void; - function only(...args: any[]): void; - function optional(...args: any[]): void; - function optionalKeys(...args: any[]): void; - function options(...args: any[]): void; - function or(...args: any[]): void; - function pattern(...args: any[]): void; - function raw(...args: any[]): void; - function rename(...args: any[]): void; - function required(...args: any[]): void; - function requiredKeys(...args: any[]): void; - function schema(...args: any[]): void; - function strict(...args: any[]): void; - function strip(...args: any[]): void; - function tags(...args: any[]): void; - function type(...args: any[]): void; - function unit(...args: any[]): void; - function unknown(...args: any[]): void; - function valid(...args: any[]): void; - function validate(...args: any[]): void; - function when(...args: any[]): void; - function without(...args: any[]): void; - function xor(...args: any[]): void; } namespace extensionsSchema { const isImmutable: boolean; - const isJoi: boolean; - const schemaType: string; - function allow(...args: any[]): void; - function applyFunctionToChildren(...args: any[]): void; - function checkOptions(...args: any[]): void; - function clone(...args: any[]): void; - function concat(...args: any[]): void; - function createError(...args: any[]): void; - function createOverrideError(...args: any[]): void; - function describe(...args: any[]): void; - function description(...args: any[]): void; - function disallow(...args: any[]): void; - function empty(...args: any[]): void; - function equal(...args: any[]): void; - function error(...args: any[]): void; - function example(...args: any[]): void; - function exist(...args: any[]): void; - function forbidden(...args: any[]): void; - function invalid(...args: any[]): void; - function items(...args: any[]): void; - function label(...args: any[]): void; - function length(...args: any[]): void; - function max(...args: any[]): void; - function meta(...args: any[]): void; - function min(...args: any[]): void; - function not(...args: any[]): void; - function notes(...args: any[]): void; - function only(...args: any[]): void; - function optional(...args: any[]): void; - function options(...args: any[]): void; - function ordered(...args: any[]): void; - function raw(...args: any[]): void; - function required(...args: any[]): void; - function single(...args: any[]): void; - function sparse(...args: any[]): void; - function strict(...args: any[]): void; - function strip(...args: any[]): void; - function tags(...args: any[]): void; - function unique(...args: any[]): void; - function unit(...args: any[]): void; - function valid(...args: any[]): void; - function validate(...args: any[]): void; - function when(...args: any[]): void; } } From 40d39fb1fa3273064ee4bd13daba32ffb21f0c36 Mon Sep 17 00:00:00 2001 From: Christopher Woodland Date: Thu, 1 Mar 2018 14:02:28 -0500 Subject: [PATCH 4/6] Change Joi export to export import Joi = require("joi"); --- types/frisby/index.d.ts | 164 +--------------------------------------- 1 file changed, 1 insertion(+), 163 deletions(-) diff --git a/types/frisby/index.d.ts b/types/frisby/index.d.ts index 899e45ef5e..bdec0fbf7f 100644 --- a/types/frisby/index.d.ts +++ b/types/frisby/index.d.ts @@ -12,169 +12,7 @@ import { Response } from 'node-fetch'; // Import all definitions from node-fetch // #region Joi Methods // Reference file: https://github.com/hapijs/joi -export namespace Joi { - const isImmutable: boolean; - const isJoi: boolean; - const schemaType: string; - const version: string; - function allow(...args: any[]): void; - function alt(args: any): any; - function alternatives(args: any): any; - function any(args: any): any; - function applyFunctionToChildren(...args: any[]): void; - function array(args: any): any; - function assert(value: any, schema: any, message: string): void; - function attempt(value: any, schema: any, message: string): any; - function binary(args: any): any; - function bool(args: any): any; - function checkOptions(...args: any[]): void; - function clone(...args: any[]): void; - function compile(schema: any): any; - function concat(...args: any[]): void; - function createError(...args: any[]): void; - function createOverrideError(...args: any[]): void; - function date(args: any): any; - function defaults(fn: any): any; - function describe(args: any): any; - function description(...args: any[]): void; - function disallow(...args: any[]): void; - function empty(...args: any[]): void; - function equal(...args: any[]): void; - function error(...args: any[]): void; - function example(...args: any[]): void; - function exist(...args: any[]): void; - function extend(args: any): any; - function forbidden(...args: any[]): void; - function func(args: any): any; - function invalid(...args: any[]): void; - function isRef(ref: any): any; - function label(...args: any[]): void; - function lazy(fn: any): any; - function meta(...args: any[]): void; - function not(...args: any[]): void; - function notes(...args: any[]): void; - function number(args: any): any; - function object(args: any): any; - function only(...args: any[]): void; - function optional(...args: any[]): void; - function options(...args: any[]): void; - function raw(...args: any[]): void; - function reach(schema: any, path: any): any; - function ref(args: any): any; - function required(...args: any[]): void; - function strict(...args: any[]): void; - function string(args: any): any; - function strip(...args: any[]): void; - function tags(...args: any[]): void; - function unit(...args: any[]): void; - function valid(...args: any[]): void; - function validate(value: any, args: any): any; - function when(...args: any[]): void; - - namespace extensionSchema { - const isImmutable: boolean; - const isJoi: boolean; - const schemaType: string; - function allow(...args: any[]): void; - function and(...args: any[]): void; - function applyFunctionToChildren(...args: any[]): void; - function assert(...args: any[]): void; - function checkOptions(...args: any[]): void; - function clone(...args: any[]): void; - function concat(...args: any[]): void; - function createError(...args: any[]): void; - function createOverrideError(...args: any[]): void; - function describe(...args: any[]): void; - function description(...args: any[]): void; - function disallow(...args: any[]): void; - function empty(...args: any[]): void; - function equal(...args: any[]): void; - function error(...args: any[]): void; - function example(...args: any[]): void; - function exist(...args: any[]): void; - function forbidden(...args: any[]): void; - function forbiddenKeys(...args: any[]): void; - function invalid(...args: any[]): void; - function keys(...args: any[]): void; - function label(...args: any[]): void; - function length(...args: any[]): void; - function max(...args: any[]): void; - function meta(...args: any[]): void; - function min(...args: any[]): void; - function nand(...args: any[]): void; - function not(...args: any[]): void; - function notes(...args: any[]): void; - function only(...args: any[]): void; - function optional(...args: any[]): void; - function optionalKeys(...args: any[]): void; - function options(...args: any[]): void; - function or(...args: any[]): void; - function pattern(...args: any[]): void; - function raw(...args: any[]): void; - function rename(...args: any[]): void; - function required(...args: any[]): void; - function requiredKeys(...args: any[]): void; - function schema(...args: any[]): void; - function strict(...args: any[]): void; - function strip(...args: any[]): void; - function tags(...args: any[]): void; - function type(...args: any[]): void; - function unit(...args: any[]): void; - function unknown(...args: any[]): void; - function valid(...args: any[]): void; - function validate(...args: any[]): void; - function when(...args: any[]): void; - function without(...args: any[]): void; - function xor(...args: any[]): void; - } - - namespace extensionsSchema { - const isImmutable: boolean; - const isJoi: boolean; - const schemaType: string; - function allow(...args: any[]): void; - function applyFunctionToChildren(...args: any[]): void; - function checkOptions(...args: any[]): void; - function clone(...args: any[]): void; - function concat(...args: any[]): void; - function createError(...args: any[]): void; - function createOverrideError(...args: any[]): void; - function describe(...args: any[]): void; - function description(...args: any[]): void; - function disallow(...args: any[]): void; - function empty(...args: any[]): void; - function equal(...args: any[]): void; - function error(...args: any[]): void; - function example(...args: any[]): void; - function exist(...args: any[]): void; - function forbidden(...args: any[]): void; - function invalid(...args: any[]): void; - function items(...args: any[]): void; - function label(...args: any[]): void; - function length(...args: any[]): void; - function max(...args: any[]): void; - function meta(...args: any[]): void; - function min(...args: any[]): void; - function not(...args: any[]): void; - function notes(...args: any[]): void; - function only(...args: any[]): void; - function optional(...args: any[]): void; - function options(...args: any[]): void; - function ordered(...args: any[]): void; - function raw(...args: any[]): void; - function required(...args: any[]): void; - function single(...args: any[]): void; - function sparse(...args: any[]): void; - function strict(...args: any[]): void; - function strip(...args: any[]): void; - function tags(...args: any[]): void; - function unique(...args: any[]): void; - function unit(...args: any[]): void; - function valid(...args: any[]): void; - function validate(...args: any[]): void; - function when(...args: any[]): void; - } -} +export import Joi = require("joi"); // #endregion // #region Frisby FrisbySpec Methods From f09fdbe9da0b9b518ed2bd7e07878cc8c55e2768 Mon Sep 17 00:00:00 2001 From: Christopher Woodland Date: Thu, 1 Mar 2018 14:18:10 -0500 Subject: [PATCH 5/6] Change promise() return type. --- types/frisby/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/frisby/index.d.ts b/types/frisby/index.d.ts index bdec0fbf7f..859bb3e3db 100644 --- a/types/frisby/index.d.ts +++ b/types/frisby/index.d.ts @@ -7,7 +7,7 @@ /// // #region Imports -import { Response } from 'node-fetch'; // Import all definitions from node-fetch. +export import nodeFetch = require('node-fetch'); // Import all definitions from node-fetch. //#endregion // #region Joi Methods @@ -38,7 +38,7 @@ export class FrisbySpec { inspectStatus(): FrisbySpec; patch(url: string, params: {}): FrisbySpec; post(url: string, params: {}): FrisbySpec; - promise(): Promise; + promise(): Promise; put(url: string, params: {}): FrisbySpec; setup(opts: {}, replace: boolean): FrisbySpec; then(onFulfilled: {} | ((...args: any[]) => void), onRejected: (...args: any[]) => void): FrisbySpec; From 5b0ff4bc9f7b356fa0c1c6dc4e5628e85632912d Mon Sep 17 00:00:00 2001 From: Christopher Woodland Date: Thu, 1 Mar 2018 16:03:15 -0500 Subject: [PATCH 6/6] Add Johnny Li to Definitions by --- types/frisby/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/frisby/index.d.ts b/types/frisby/index.d.ts index 859bb3e3db..366a3998d7 100644 --- a/types/frisby/index.d.ts +++ b/types/frisby/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Frisby 2.0 // Project: https://github.com/vlucas/frisby // Definitions by: Christopher E. Woodland +// Johnny Li // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6