diff --git a/code/code-tests.ts b/code/code-tests.ts index ea956c6c2c..f90d2c9eb7 100644 --- a/code/code-tests.ts +++ b/code/code-tests.ts @@ -31,7 +31,7 @@ expect(err).to.be.an.error(Error); expect(err).to.be.an.error("Oops an error occured."); expect(err).to.be.an.error(Error, /occured/); -expect(function () { }).to.be.a.function(); +expect(func).to.be.a.function(); expect(123).to.be.a.number(); @@ -147,7 +147,7 @@ fail("This should not occur"); expect(count()).to.be.a.number(); -expect(incomplete()).to.be.null().and.not.be.an.array(); +expect(incomplete() as null).to.be.null().and.not.be.an.array(); const error = thrownAt(new Error("oops")); expect(error).to.not.be.undefined(); diff --git a/code/index.d.ts b/code/index.d.ts index 174215f5d8..dacd122915 100644 --- a/code/index.d.ts +++ b/code/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for code 4.0.0 +// Type definitions for code 4.0 // Project: https://github.com/hapijs/code // Definitions by: Prashant Tiwari // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,7 +10,7 @@ export function fail(message: string): void; /** Returns the total number of assertions created using the expect() method. */ export function count(): number; /** Returns an array of the locations where incomplete assertions were declared or null if no incomplete assertions found. */ -export function incomplete(): Array | null; +export function incomplete(): string[] | null; /** Returns the filename, line number, and column number of where the error was created. */ export function thrownAt(error?: Error): CodeError; /** Configure code. */ @@ -18,9 +18,9 @@ export const settings: Settings; type AssertionChain = Assertion & Expectation; -interface Assertion extends Grammar, Flags { } +type Assertion = Grammar & Flags; -interface Expectation extends Types, Values { } +type Expectation = Types & Values; interface Grammar { /** Connecting word. */ @@ -78,7 +78,7 @@ interface Types { /** Asserts that the reference value is a Date. */ date(): AssertionChain; /** Asserts that the reference value is an error. */ - error(type?: Object, message?: string | RegExp): AssertionChain; + error(type?: any, message?: string | RegExp): AssertionChain; /** Asserts that the reference value is a function. */ function(): AssertionChain; /** Asserts that the reference value is a number. */ @@ -153,9 +153,9 @@ interface Values { /** Asserts that the reference value is about the provided value within a delta margin of difference. */ about(value: number, delta: number): AssertionChain; /** Asserts that the reference value has the provided instanceof value. */ - instanceof(type: Object): AssertionChain; + instanceof(type: any): AssertionChain; /** Asserts that the reference value has the provided instanceof value. */ - instanceOf(type: Object): AssertionChain; + instanceOf(type: any): AssertionChain; /** Asserts that the reference value's toString() representation matches the provided regular expression. */ match(regex: RegExp): AssertionChain; /** Asserts that the reference value's toString() representation matches the provided regular expression. */ @@ -165,7 +165,9 @@ interface Values { /** Asserts that the reference value satisfies the provided validator function. */ satisfies(validator: (value: T) => boolean): AssertionChain; /** Asserts that the function reference value throws an exception when called. */ - throw(type: Object, message: string | RegExp): AssertionChain; + throw(type?: any, message?: string | RegExp): AssertionChain; + /** Asserts that the function reference value throws an exception when called. */ + throws(type?: any, message?: string | RegExp): AssertionChain; } interface Settings { diff --git a/code/tslint.json b/code/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/code/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file