diff --git a/types/assert/assert-tests.ts b/types/assert/assert-tests.ts new file mode 100644 index 0000000000..22248c18bd --- /dev/null +++ b/types/assert/assert-tests.ts @@ -0,0 +1,10 @@ +import * as assert from 'assert'; + +assert(true, "it's working"); + +assert.ok(true, "inner functions work as well"); + +assert.throws(() => {}); +assert.throws(() => {}, () => {}, "works wonderfully"); + +assert['fail'](true, true, "works like a charm"); diff --git a/types/assert/index.d.ts b/types/assert/index.d.ts new file mode 100644 index 0000000000..d79805f5af --- /dev/null +++ b/types/assert/index.d.ts @@ -0,0 +1,45 @@ +// Type definitions for commonjs-assert 1.4 +// Project: https://github.com/browserify/commonjs-assert +// Definitions by: Nico Gallinal +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function assert(value: any, message?: string): void; + +declare namespace assert { + function fail(actual?: any, expected?: any, message?: string, operator?: string): void; + + function ok(value: any, message?: string): void; + + function equal(actual: any, expected: any, message?: string): void; + + function notEqual(actual: any, expected: any, message?: string): void; + + function deepEqual(actual: any, expected: any, message?: string): void; + + function notDeepEqual(acutal: any, expected: any, message?: string): void; + + function strictEqual(actual: any, expected: any, message?: string): void; + + function notStrictEqual(actual: any, expected: any, message?: string): void; + + function throws(block: () => void, message?: string): void; + function throws(block: () => void, error: () => void | ((err: any) => boolean) | RegExp, message?: string): void; + + function doesNotThrow(block: () => void, message?: string): void; + function doesNotThrow(block: () => void, error: () => void | ((err: any) => boolean) | RegExp, message?: string): void; + + function ifError(value: any): void; + + class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; + + constructor(options?: { message?: string; actual?: any; expected?: any; operator?: string; stackStartFunction?: () => void }); + } +} + +export = assert; diff --git a/types/assert/tsconfig.json b/types/assert/tsconfig.json new file mode 100644 index 0000000000..5ab217b2ab --- /dev/null +++ b/types/assert/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "assert-tests.ts" + ] +} diff --git a/types/assert/tslint.json b/types/assert/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/assert/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}