Add types for browserify/commonjs-assert (#29188)

* add types for browserify/commonjs-assert

* fix tests and rename to 'assert'

* fix some linting errors, checking in to avoid closing of pull request

* fixed all lint errors
This commit is contained in:
Nicolás Andrés Gallinal
2018-10-02 11:37:55 -07:00
committed by Wesley Wigham
parent e72bee2ba3
commit 7aa3334626
4 changed files with 82 additions and 0 deletions
+10
View File
@@ -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");
+45
View File
@@ -0,0 +1,45 @@
// Type definitions for commonjs-assert 1.4
// Project: https://github.com/browserify/commonjs-assert
// Definitions by: Nico Gallinal <https://github.com/nicoabie>
// 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;
+24
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}