mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Minor fix for assertion predicates (#38710)
This commit is contained in:
parent
9ff24b6fc8
commit
fd0ad2985b
@ -20459,7 +20459,7 @@ namespace ts {
|
||||
const signature = getEffectsSignature((<FlowCall>flow).node);
|
||||
if (signature) {
|
||||
const predicate = getTypePredicateOfSignature(signature);
|
||||
if (predicate && predicate.kind === TypePredicateKind.AssertsIdentifier) {
|
||||
if (predicate && predicate.kind === TypePredicateKind.AssertsIdentifier && !predicate.type) {
|
||||
const predicateArgument = (<FlowCall>flow).node.arguments[predicate.parameterIndex];
|
||||
if (predicateArgument && isFalseExpression(predicateArgument)) {
|
||||
return false;
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(39,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(43,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(87,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(122,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(137,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(153,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(154,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(155,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(158,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(159,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(160,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(161,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(166,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(168,5): error TS2776: Assertions require the call target to be an identifier or qualified name.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(47,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(91,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(126,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(141,9): error TS7027: Unreachable code detected.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(157,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(158,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(159,37): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(162,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(163,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(164,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(165,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(170,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(172,5): error TS2776: Assertions require the call target to be an identifier or qualified name.
|
||||
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(174,5): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts (15 errors) ====
|
||||
@ -46,6 +46,10 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(170,5): error TS
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(false);
|
||||
x;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
@ -208,7 +212,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(170,5): error TS
|
||||
assert(typeof x === "string"); // Error
|
||||
~~~~~~
|
||||
!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
|
||||
!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:165:11: 'assert' needs an explicit type annotation.
|
||||
!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:169:11: 'assert' needs an explicit type annotation.
|
||||
const a = [assert];
|
||||
a[0](typeof x === "string"); // Error
|
||||
~~~~
|
||||
@ -217,7 +221,7 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(170,5): error TS
|
||||
t1.assert(typeof x === "string"); // Error
|
||||
~~~~~~~~~
|
||||
!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
|
||||
!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:169:11: 't1' needs an explicit type annotation.
|
||||
!!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:173:11: 't1' needs an explicit type annotation.
|
||||
const t2: Test = new Test();
|
||||
t2.assert(typeof x === "string");
|
||||
}
|
||||
|
||||
@ -29,6 +29,10 @@ function f01(x: unknown) {
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(false);
|
||||
x;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
@ -229,6 +233,10 @@ function f01(x) {
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(false);
|
||||
x;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
|
||||
@ -90,6 +90,13 @@ function f01(x: unknown) {
|
||||
>x[0].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(false);
|
||||
>assertIsArrayOfStrings : Symbol(assertIsArrayOfStrings, Decl(assertionTypePredicates1.ts, 5, 73))
|
||||
|
||||
x;
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 9, 13))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
@ -127,418 +134,418 @@ function f01(x: unknown) {
|
||||
}
|
||||
|
||||
function f02(x: string | undefined) {
|
||||
>f02 : Symbol(f02, Decl(assertionTypePredicates1.ts, 44, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>f02 : Symbol(f02, Decl(assertionTypePredicates1.ts, 48, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
|
||||
if (!!true) {
|
||||
assert(x);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x !== undefined);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 3, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
assertDefined(x);
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 6, 83))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 46, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 50, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
|
||||
function f03(x: string | undefined, assert: (value: unknown) => asserts value) {
|
||||
>f03 : Symbol(f03, Decl(assertionTypePredicates1.ts, 59, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 61, 13))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 61, 35))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 61, 45))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 61, 45))
|
||||
>f03 : Symbol(f03, Decl(assertionTypePredicates1.ts, 63, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 65, 13))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 65, 35))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 65, 45))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 65, 45))
|
||||
|
||||
assert(x);
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 61, 35))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 61, 13))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 65, 35))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 65, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 61, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 65, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
namespace Debug {
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 64, 1))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 68, 1))
|
||||
|
||||
export declare function assert(value: unknown, message?: string): asserts value;
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 67, 35))
|
||||
>message : Symbol(message, Decl(assertionTypePredicates1.ts, 67, 50))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 67, 35))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 71, 35))
|
||||
>message : Symbol(message, Decl(assertionTypePredicates1.ts, 71, 50))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 71, 35))
|
||||
|
||||
export declare function assertDefined<T>(value: T): asserts value is NonNullable<T>;
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 67, 84))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 68, 42))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 68, 45))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 68, 42))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 68, 45))
|
||||
>assertDefined : Symbol(assertDefined, Decl(assertionTypePredicates1.ts, 71, 84))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 72, 42))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 72, 45))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 72, 42))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 72, 45))
|
||||
>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 68, 42))
|
||||
>T : Symbol(T, Decl(assertionTypePredicates1.ts, 72, 42))
|
||||
}
|
||||
|
||||
function f10(x: string | undefined) {
|
||||
>f10 : Symbol(f10, Decl(assertionTypePredicates1.ts, 69, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>f10 : Symbol(f10, Decl(assertionTypePredicates1.ts, 73, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
|
||||
if (!!true) {
|
||||
Debug.assert(x);
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 64, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 68, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assert(x !== undefined);
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 64, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 68, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assertDefined(x);
|
||||
>Debug.assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 67, 84))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 64, 1))
|
||||
>assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 67, 84))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>Debug.assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 71, 84))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 68, 1))
|
||||
>assertDefined : Symbol(Debug.assertDefined, Decl(assertionTypePredicates1.ts, 71, 84))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
if (!!true) {
|
||||
Debug.assert(false);
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 64, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 66, 17))
|
||||
>Debug.assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
>Debug : Symbol(Debug, Decl(assertionTypePredicates1.ts, 68, 1))
|
||||
>assert : Symbol(Debug.assert, Decl(assertionTypePredicates1.ts, 70, 17))
|
||||
|
||||
x; // Unreachable
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 71, 13))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 75, 13))
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
assert(value: unknown): asserts value {
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 91, 11))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 91, 11))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 95, 11))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 95, 11))
|
||||
|
||||
if (value) return;
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 91, 11))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 95, 11))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
isTest2(): this is Test2 {
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 94, 5))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 123, 1))
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 98, 5))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
|
||||
|
||||
return this instanceof Test2;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 123, 1))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
|
||||
}
|
||||
assertIsTest2(): asserts this is Test2 {
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 97, 5))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 123, 1))
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
|
||||
|
||||
if (this instanceof Test2) return;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 123, 1))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
assertThis(): asserts this {
|
||||
>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 105, 5))
|
||||
|
||||
if (!this) return;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
bar() {
|
||||
>bar : Symbol(Test.bar, Decl(assertionTypePredicates1.ts, 105, 5))
|
||||
>bar : Symbol(Test.bar, Decl(assertionTypePredicates1.ts, 109, 5))
|
||||
|
||||
this.assertThis();
|
||||
>this.assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
>this.assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 105, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>assertThis : Symbol(Test.assertThis, Decl(assertionTypePredicates1.ts, 105, 5))
|
||||
|
||||
this;
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
}
|
||||
foo(x: unknown) {
|
||||
>foo : Symbol(Test.foo, Decl(assertionTypePredicates1.ts, 109, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 110, 8))
|
||||
>foo : Symbol(Test.foo, Decl(assertionTypePredicates1.ts, 113, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 114, 8))
|
||||
|
||||
this.assert(typeof x === "string");
|
||||
>this.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 110, 8))
|
||||
>this.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 114, 8))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 110, 8))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 114, 8))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
if (this.isTest2()) {
|
||||
>this.isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 94, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 94, 5))
|
||||
>this.isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 98, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 98, 5))
|
||||
|
||||
this.z;
|
||||
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
}
|
||||
this.assertIsTest2();
|
||||
>this.assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 97, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 97, 5))
|
||||
>this.assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
|
||||
this.z;
|
||||
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
}
|
||||
baz(x: number) {
|
||||
>baz : Symbol(Test.baz, Decl(assertionTypePredicates1.ts, 118, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 119, 8))
|
||||
>baz : Symbol(Test.baz, Decl(assertionTypePredicates1.ts, 122, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 123, 8))
|
||||
|
||||
this.assert(false);
|
||||
>this.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>this.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>this : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
|
||||
x; // Unreachable
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 119, 8))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 123, 8))
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 extends Test {
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 123, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>Test2 : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
z = 0;
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
}
|
||||
|
||||
class Derived extends Test {
|
||||
>Derived : Symbol(Derived, Decl(assertionTypePredicates1.ts, 127, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>Derived : Symbol(Derived, Decl(assertionTypePredicates1.ts, 131, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
foo(x: unknown) {
|
||||
>foo : Symbol(Derived.foo, Decl(assertionTypePredicates1.ts, 129, 28))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 130, 8))
|
||||
>foo : Symbol(Derived.foo, Decl(assertionTypePredicates1.ts, 133, 28))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 134, 8))
|
||||
|
||||
super.assert(typeof x === "string");
|
||||
>super.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>super : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 130, 8))
|
||||
>super.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>super : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 134, 8))
|
||||
|
||||
x.length;
|
||||
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 130, 8))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 134, 8))
|
||||
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
baz(x: number) {
|
||||
>baz : Symbol(Derived.baz, Decl(assertionTypePredicates1.ts, 133, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 134, 8))
|
||||
>baz : Symbol(Derived.baz, Decl(assertionTypePredicates1.ts, 137, 5))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 138, 8))
|
||||
|
||||
super.assert(false);
|
||||
>super.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>super : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>super.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>super : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
|
||||
x; // Unreachable
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 134, 8))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 138, 8))
|
||||
}
|
||||
}
|
||||
|
||||
function f11(items: Test[]) {
|
||||
>f11 : Symbol(f11, Decl(assertionTypePredicates1.ts, 138, 1))
|
||||
>items : Symbol(items, Decl(assertionTypePredicates1.ts, 140, 13))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>f11 : Symbol(f11, Decl(assertionTypePredicates1.ts, 142, 1))
|
||||
>items : Symbol(items, Decl(assertionTypePredicates1.ts, 144, 13))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
for (let item of items) {
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 141, 12))
|
||||
>items : Symbol(items, Decl(assertionTypePredicates1.ts, 140, 13))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 145, 12))
|
||||
>items : Symbol(items, Decl(assertionTypePredicates1.ts, 144, 13))
|
||||
|
||||
if (item.isTest2()) {
|
||||
>item.isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 94, 5))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 141, 12))
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 94, 5))
|
||||
>item.isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 98, 5))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 145, 12))
|
||||
>isTest2 : Symbol(Test.isTest2, Decl(assertionTypePredicates1.ts, 98, 5))
|
||||
|
||||
item.z;
|
||||
>item.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 141, 12))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>item.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 145, 12))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
}
|
||||
item.assertIsTest2();
|
||||
>item.assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 97, 5))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 141, 12))
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 97, 5))
|
||||
>item.assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 145, 12))
|
||||
>assertIsTest2 : Symbol(Test.assertIsTest2, Decl(assertionTypePredicates1.ts, 101, 5))
|
||||
|
||||
item.z;
|
||||
>item.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 141, 12))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 125, 26))
|
||||
>item.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
>item : Symbol(item, Decl(assertionTypePredicates1.ts, 145, 12))
|
||||
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
|
||||
}
|
||||
}
|
||||
|
||||
// Invalid constructs
|
||||
|
||||
declare let Q1: new (x: unknown) => x is string;
|
||||
>Q1 : Symbol(Q1, Decl(assertionTypePredicates1.ts, 152, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 152, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 152, 21))
|
||||
>Q1 : Symbol(Q1, Decl(assertionTypePredicates1.ts, 156, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 156, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 156, 21))
|
||||
|
||||
declare let Q2: new (x: boolean) => asserts x;
|
||||
>Q2 : Symbol(Q2, Decl(assertionTypePredicates1.ts, 153, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 153, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 153, 21))
|
||||
>Q2 : Symbol(Q2, Decl(assertionTypePredicates1.ts, 157, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 157, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 157, 21))
|
||||
|
||||
declare let Q3: new (x: unknown) => asserts x is string;
|
||||
>Q3 : Symbol(Q3, Decl(assertionTypePredicates1.ts, 154, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 154, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 154, 21))
|
||||
>Q3 : Symbol(Q3, Decl(assertionTypePredicates1.ts, 158, 11))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 158, 21))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 158, 21))
|
||||
|
||||
declare class Wat {
|
||||
>Wat : Symbol(Wat, Decl(assertionTypePredicates1.ts, 154, 56))
|
||||
>Wat : Symbol(Wat, Decl(assertionTypePredicates1.ts, 158, 56))
|
||||
|
||||
get p1(): this is string;
|
||||
>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 156, 19), Decl(assertionTypePredicates1.ts, 157, 29))
|
||||
>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 160, 19), Decl(assertionTypePredicates1.ts, 161, 29))
|
||||
|
||||
set p1(x: this is string);
|
||||
>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 156, 19), Decl(assertionTypePredicates1.ts, 157, 29))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 158, 11))
|
||||
>p1 : Symbol(Wat.p1, Decl(assertionTypePredicates1.ts, 160, 19), Decl(assertionTypePredicates1.ts, 161, 29))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 162, 11))
|
||||
|
||||
get p2(): asserts this is string;
|
||||
>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 158, 30), Decl(assertionTypePredicates1.ts, 159, 37))
|
||||
>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 162, 30), Decl(assertionTypePredicates1.ts, 163, 37))
|
||||
|
||||
set p2(x: asserts this is string);
|
||||
>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 158, 30), Decl(assertionTypePredicates1.ts, 159, 37))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 160, 11))
|
||||
>p2 : Symbol(Wat.p2, Decl(assertionTypePredicates1.ts, 162, 30), Decl(assertionTypePredicates1.ts, 163, 37))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 164, 11))
|
||||
}
|
||||
|
||||
function f20(x: unknown) {
|
||||
>f20 : Symbol(f20, Decl(assertionTypePredicates1.ts, 161, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 163, 13))
|
||||
>f20 : Symbol(f20, Decl(assertionTypePredicates1.ts, 165, 1))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 167, 13))
|
||||
|
||||
const assert = (value: unknown): asserts value => {}
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 164, 9))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 164, 20))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 164, 20))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 168, 9))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 168, 20))
|
||||
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 168, 20))
|
||||
|
||||
assert(typeof x === "string"); // Error
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 164, 9))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 163, 13))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 168, 9))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 167, 13))
|
||||
|
||||
const a = [assert];
|
||||
>a : Symbol(a, Decl(assertionTypePredicates1.ts, 166, 9))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 164, 9))
|
||||
>a : Symbol(a, Decl(assertionTypePredicates1.ts, 170, 9))
|
||||
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 168, 9))
|
||||
|
||||
a[0](typeof x === "string"); // Error
|
||||
>a : Symbol(a, Decl(assertionTypePredicates1.ts, 166, 9))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 163, 13))
|
||||
>a : Symbol(a, Decl(assertionTypePredicates1.ts, 170, 9))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 167, 13))
|
||||
|
||||
const t1 = new Test();
|
||||
>t1 : Symbol(t1, Decl(assertionTypePredicates1.ts, 168, 9))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>t1 : Symbol(t1, Decl(assertionTypePredicates1.ts, 172, 9))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
t1.assert(typeof x === "string"); // Error
|
||||
>t1.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>t1 : Symbol(t1, Decl(assertionTypePredicates1.ts, 168, 9))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 163, 13))
|
||||
>t1.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>t1 : Symbol(t1, Decl(assertionTypePredicates1.ts, 172, 9))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 167, 13))
|
||||
|
||||
const t2: Test = new Test();
|
||||
>t2 : Symbol(t2, Decl(assertionTypePredicates1.ts, 170, 9))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 88, 1))
|
||||
>t2 : Symbol(t2, Decl(assertionTypePredicates1.ts, 174, 9))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 92, 1))
|
||||
|
||||
t2.assert(typeof x === "string");
|
||||
>t2.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>t2 : Symbol(t2, Decl(assertionTypePredicates1.ts, 170, 9))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 90, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 163, 13))
|
||||
>t2.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>t2 : Symbol(t2, Decl(assertionTypePredicates1.ts, 174, 9))
|
||||
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 94, 12))
|
||||
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 167, 13))
|
||||
}
|
||||
|
||||
// Repro from #35940
|
||||
|
||||
interface Thing {
|
||||
>Thing : Symbol(Thing, Decl(assertionTypePredicates1.ts, 172, 1))
|
||||
>Thing : Symbol(Thing, Decl(assertionTypePredicates1.ts, 176, 1))
|
||||
|
||||
good: boolean;
|
||||
>good : Symbol(Thing.good, Decl(assertionTypePredicates1.ts, 176, 17))
|
||||
>good : Symbol(Thing.good, Decl(assertionTypePredicates1.ts, 180, 17))
|
||||
|
||||
isGood(): asserts this is GoodThing;
|
||||
>isGood : Symbol(Thing.isGood, Decl(assertionTypePredicates1.ts, 177, 18))
|
||||
>GoodThing : Symbol(GoodThing, Decl(assertionTypePredicates1.ts, 179, 1))
|
||||
>isGood : Symbol(Thing.isGood, Decl(assertionTypePredicates1.ts, 181, 18))
|
||||
>GoodThing : Symbol(GoodThing, Decl(assertionTypePredicates1.ts, 183, 1))
|
||||
}
|
||||
|
||||
interface GoodThing {
|
||||
>GoodThing : Symbol(GoodThing, Decl(assertionTypePredicates1.ts, 179, 1))
|
||||
>GoodThing : Symbol(GoodThing, Decl(assertionTypePredicates1.ts, 183, 1))
|
||||
|
||||
good: true;
|
||||
>good : Symbol(GoodThing.good, Decl(assertionTypePredicates1.ts, 181, 21))
|
||||
>good : Symbol(GoodThing.good, Decl(assertionTypePredicates1.ts, 185, 21))
|
||||
}
|
||||
|
||||
function example1(things: Thing[]) {
|
||||
>example1 : Symbol(example1, Decl(assertionTypePredicates1.ts, 183, 1))
|
||||
>things : Symbol(things, Decl(assertionTypePredicates1.ts, 185, 18))
|
||||
>Thing : Symbol(Thing, Decl(assertionTypePredicates1.ts, 172, 1))
|
||||
>example1 : Symbol(example1, Decl(assertionTypePredicates1.ts, 187, 1))
|
||||
>things : Symbol(things, Decl(assertionTypePredicates1.ts, 189, 18))
|
||||
>Thing : Symbol(Thing, Decl(assertionTypePredicates1.ts, 176, 1))
|
||||
|
||||
for (let thing of things) {
|
||||
>thing : Symbol(thing, Decl(assertionTypePredicates1.ts, 186, 12))
|
||||
>things : Symbol(things, Decl(assertionTypePredicates1.ts, 185, 18))
|
||||
>thing : Symbol(thing, Decl(assertionTypePredicates1.ts, 190, 12))
|
||||
>things : Symbol(things, Decl(assertionTypePredicates1.ts, 189, 18))
|
||||
|
||||
thing.isGood();
|
||||
>thing.isGood : Symbol(Thing.isGood, Decl(assertionTypePredicates1.ts, 177, 18))
|
||||
>thing : Symbol(thing, Decl(assertionTypePredicates1.ts, 186, 12))
|
||||
>isGood : Symbol(Thing.isGood, Decl(assertionTypePredicates1.ts, 177, 18))
|
||||
>thing.isGood : Symbol(Thing.isGood, Decl(assertionTypePredicates1.ts, 181, 18))
|
||||
>thing : Symbol(thing, Decl(assertionTypePredicates1.ts, 190, 12))
|
||||
>isGood : Symbol(Thing.isGood, Decl(assertionTypePredicates1.ts, 181, 18))
|
||||
|
||||
thing.good;
|
||||
>thing.good : Symbol(good, Decl(assertionTypePredicates1.ts, 176, 17), Decl(assertionTypePredicates1.ts, 181, 21))
|
||||
>thing : Symbol(thing, Decl(assertionTypePredicates1.ts, 186, 12))
|
||||
>good : Symbol(good, Decl(assertionTypePredicates1.ts, 176, 17), Decl(assertionTypePredicates1.ts, 181, 21))
|
||||
>thing.good : Symbol(good, Decl(assertionTypePredicates1.ts, 180, 17), Decl(assertionTypePredicates1.ts, 185, 21))
|
||||
>thing : Symbol(thing, Decl(assertionTypePredicates1.ts, 190, 12))
|
||||
>good : Symbol(good, Decl(assertionTypePredicates1.ts, 180, 17), Decl(assertionTypePredicates1.ts, 185, 21))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -126,6 +126,19 @@ function f01(x: unknown) {
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assertIsArrayOfStrings(false);
|
||||
>assertIsArrayOfStrings(false) : void
|
||||
>assertIsArrayOfStrings : (value: unknown) => asserts value is string[]
|
||||
>false : false
|
||||
|
||||
x;
|
||||
>x : unknown
|
||||
}
|
||||
if (!!true) {
|
||||
>!!true : true
|
||||
>!true : false
|
||||
>true : true
|
||||
|
||||
assert(x === undefined || typeof x === "string");
|
||||
|
||||
@ -32,6 +32,10 @@ function f01(x: unknown) {
|
||||
assertIsArrayOfStrings(x);
|
||||
x[0].length;
|
||||
}
|
||||
if (!!true) {
|
||||
assertIsArrayOfStrings(false);
|
||||
x;
|
||||
}
|
||||
if (!!true) {
|
||||
assert(x === undefined || typeof x === "string");
|
||||
x; // string | undefined
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user