From 472056e954b62b303bd0026111d7126eb5a170ea Mon Sep 17 00:00:00 2001 From: Curtis Hawthorne Date: Tue, 27 Feb 2018 18:33:17 -0800 Subject: [PATCH 1/4] add support for custom Error subclasses --- types/tape/index.d.ts | 4 ++-- types/tape/tape-tests.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/tape/index.d.ts b/types/tape/index.d.ts index 581a669606..936f2ac491 100644 --- a/types/tape/index.d.ts +++ b/types/tape/index.d.ts @@ -193,13 +193,13 @@ declare namespace tape { * expected, if present, must be a RegExp or Function, which is used to test the exception object. */ throws(fn: () => void, msg?: string): void; - throws(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void; + throws(fn: () => void, exceptionExpected: RegExp | Function, msg?: string): void; /** * Assert that the function call fn() does not throw an exception. */ doesNotThrow(fn: () => void, msg?: string): void; - doesNotThrow(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void; + doesNotThrow(fn: () => void, exceptionExpected: RegExp | Function, msg?: string): void; /** * Print a message without breaking the tap output. diff --git a/types/tape/tape-tests.ts b/types/tape/tape-tests.ts index 6f5ad605e5..5b86ef31f7 100644 --- a/types/tape/tape-tests.ts +++ b/types/tape/tape-tests.ts @@ -28,6 +28,13 @@ rs = tape.createStream(sopts); var htest: typeof tape; htest = tape.createHarness(); +class CustomException extends Error { + constructor(message?: string) { + super(message); + Object.setPrototypeOf(this, new.target.prototype); + } +} + tape(name, (test: tape.Test) => { @@ -146,11 +153,15 @@ tape(name, (test: tape.Test) => { test.throws(fn, msg); test.throws(fn, exceptionExpected); test.throws(fn, exceptionExpected, msg); + test.throws(fn, CustomException); + test.throws(fn, CustomException, msg); test.doesNotThrow(fn); test.doesNotThrow(fn, msg); test.doesNotThrow(fn, exceptionExpected); test.doesNotThrow(fn, exceptionExpected, msg); + test.doesNotThrow(fn, CustomException); + test.doesNotThrow(fn, CustomException, msg); test.test(name, (st) => { t = st; From 627a65914771debabdb46012ed20928c746ea527 Mon Sep 17 00:00:00 2001 From: Curtis Hawthorne Date: Wed, 28 Feb 2018 09:47:32 -0800 Subject: [PATCH 2/4] TypeScript 2.2 --- types/tape/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/tape/index.d.ts b/types/tape/index.d.ts index 936f2ac491..cb087b415a 100644 --- a/types/tape/index.d.ts +++ b/types/tape/index.d.ts @@ -5,6 +5,7 @@ // Dennis Schwartz // Michael Henretty // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// From 01fe9e8b52c28b711b757a88d801e1d59b010ab1 Mon Sep 17 00:00:00 2001 From: Curtis Hawthorne Date: Wed, 28 Feb 2018 10:21:10 -0800 Subject: [PATCH 3/4] fix deps --- types/cwise-parser/index.d.ts | 1 + types/typedarray-pool/index.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/types/cwise-parser/index.d.ts b/types/cwise-parser/index.d.ts index d2a06fd7f1..f2f9dea473 100644 --- a/types/cwise-parser/index.d.ts +++ b/types/cwise-parser/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/scijs/cwise-parser#readme // Definitions by: taoqf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 declare namespace cwise_parser { interface CompiledArgument { diff --git a/types/typedarray-pool/index.d.ts b/types/typedarray-pool/index.d.ts index 34bcc7adf7..9b3ae99b1f 100644 --- a/types/typedarray-pool/index.d.ts +++ b/types/typedarray-pool/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/mikolalysenko/typedarray-pool // Definitions by: Giff Song // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 type DataType = 'uint8' | 'uint16' | 'uint32' | 'int8' | 'int16' | 'int32' | From 47262025cff6a01dce5ee5e3e4b22d4f3c021240 Mon Sep 17 00:00:00 2001 From: Curtis Hawthorne Date: Thu, 1 Mar 2018 09:52:57 -0800 Subject: [PATCH 4/4] remove need for ts 2.2 --- types/cwise-parser/index.d.ts | 1 - types/tape/index.d.ts | 1 - types/tape/tape-tests.ts | 1 - types/typedarray-pool/index.d.ts | 1 - 4 files changed, 4 deletions(-) diff --git a/types/cwise-parser/index.d.ts b/types/cwise-parser/index.d.ts index f2f9dea473..d2a06fd7f1 100644 --- a/types/cwise-parser/index.d.ts +++ b/types/cwise-parser/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/scijs/cwise-parser#readme // Definitions by: taoqf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 declare namespace cwise_parser { interface CompiledArgument { diff --git a/types/tape/index.d.ts b/types/tape/index.d.ts index cb087b415a..936f2ac491 100644 --- a/types/tape/index.d.ts +++ b/types/tape/index.d.ts @@ -5,7 +5,6 @@ // Dennis Schwartz // Michael Henretty // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 /// diff --git a/types/tape/tape-tests.ts b/types/tape/tape-tests.ts index 5b86ef31f7..0c67629f58 100644 --- a/types/tape/tape-tests.ts +++ b/types/tape/tape-tests.ts @@ -31,7 +31,6 @@ htest = tape.createHarness(); class CustomException extends Error { constructor(message?: string) { super(message); - Object.setPrototypeOf(this, new.target.prototype); } } diff --git a/types/typedarray-pool/index.d.ts b/types/typedarray-pool/index.d.ts index 9b3ae99b1f..34bcc7adf7 100644 --- a/types/typedarray-pool/index.d.ts +++ b/types/typedarray-pool/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/mikolalysenko/typedarray-pool // Definitions by: Giff Song // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 type DataType = 'uint8' | 'uint16' | 'uint32' | 'int8' | 'int16' | 'int32' |