🤖 Merge PR #46583 minimalistic-assert: use assertion signature by @yoursunny

This commit is contained in:
Junxiao Shi 2020-08-08 07:41:19 -04:00 committed by GitHub
parent f0841a3126
commit 3844f3456b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -2,8 +2,9 @@
// Project: https://github.com/calvinmetcalf/minimalistic-assert
// Definitions by: Junxiao Shi <https://github.com/yoursunny>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.7
declare function assert(val: any, msg?: string): void;
declare function assert(val: any, msg?: string): asserts val;
declare namespace assert {
function equal<T>(l: T, r: T, msg?: string): void;

View File

@ -8,3 +8,11 @@ assert(0, "error");
assert.equal(1, 1);
assert.equal(2, 1, "error");
assert.equal("ok", "ok");
() => {
const x: number|string = 1;
assert(typeof x === "number");
// $ExpectType number
x;
};