Skip to content

Commit 0595d61

Browse files
committed
Accept new baselines
1 parent 894cc63 commit 0595d61

8 files changed

+300
-83
lines changed

tests/baselines/reference/assertionTypePredicates1.errors.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(121,15): error T
55
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(122,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
66
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(123,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
77
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(124,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
8+
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(129,5): error TS2775: Control flow effects of calls to assertion and never-returning functions are reflected only when every variable or property referenced in the function expression is declared with an explicit type annotation.
9+
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(131,5): error TS2776: Control flow effects of calls to assertion and never-returning functions are reflected only when the function expression is an identifier or qualified-name.
10+
tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(133,5): error TS2775: Control flow effects of calls to assertion and never-returning functions are reflected only when every variable or property referenced in the function expression is declared with an explicit type annotation.
811

912

10-
==== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts (7 errors) ====
13+
==== tests/cases/conformance/controlFlow/assertionTypePredicates1.ts (10 errors) ====
1114
declare function isString(value: unknown): value is string;
1215
declare function isArrayOfStrings(value: unknown): value is string[];
1316

@@ -147,4 +150,21 @@ tests/cases/conformance/controlFlow/assertionTypePredicates1.ts(124,15): error T
147150
~~~~~~~~~~~~~~~~~~~~~~
148151
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
149152
}
153+
154+
function f20(x: unknown) {
155+
const assert = (value: unknown): asserts value => {}
156+
assert(typeof x === "string"); // Error
157+
~~~~~~
158+
!!! error TS2775: Control flow effects of calls to assertion and never-returning functions are reflected only when every variable or property referenced in the function expression is declared with an explicit type annotation.
159+
const a = [assert];
160+
a[0](typeof x === "string"); // Error
161+
~~~~
162+
!!! error TS2776: Control flow effects of calls to assertion and never-returning functions are reflected only when the function expression is an identifier or qualified-name.
163+
const t1 = new Test();
164+
t1.assert(typeof x === "string"); // Error
165+
~~~~~~~~~
166+
!!! error TS2775: Control flow effects of calls to assertion and never-returning functions are reflected only when every variable or property referenced in the function expression is declared with an explicit type annotation.
167+
const t2: Test = new Test();
168+
t2.assert(typeof x === "string");
169+
}
150170

tests/baselines/reference/assertionTypePredicates1.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ declare class Wat {
124124
get p2(): asserts this is string;
125125
set p2(x: asserts this is string);
126126
}
127+
128+
function f20(x: unknown) {
129+
const assert = (value: unknown): asserts value => {}
130+
assert(typeof x === "string"); // Error
131+
const a = [assert];
132+
a[0](typeof x === "string"); // Error
133+
const t1 = new Test();
134+
t1.assert(typeof x === "string"); // Error
135+
const t2: Test = new Test();
136+
t2.assert(typeof x === "string");
137+
}
127138

128139

129140
//// [assertionTypePredicates1.js]
@@ -250,6 +261,16 @@ var Test2 = /** @class */ (function (_super) {
250261
}
251262
return Test2;
252263
}(Test));
264+
function f20(x) {
265+
var assert = function (value) { };
266+
assert(typeof x === "string"); // Error
267+
var a = [assert];
268+
a[0](typeof x === "string"); // Error
269+
var t1 = new Test();
270+
t1.assert(typeof x === "string"); // Error
271+
var t2 = new Test();
272+
t2.assert(typeof x === "string");
273+
}
253274

254275

255276
//// [assertionTypePredicates1.d.ts]
@@ -287,3 +308,4 @@ declare class Wat {
287308
get p2(): asserts this is string;
288309
set p2(x: asserts this is string);
289310
}
311+
declare function f20(x: unknown): void;

tests/baselines/reference/assertionTypePredicates1.symbols

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,46 @@ declare class Wat {
357357
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 123, 11))
358358
}
359359

360+
function f20(x: unknown) {
361+
>f20 : Symbol(f20, Decl(assertionTypePredicates1.ts, 124, 1))
362+
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 126, 13))
363+
364+
const assert = (value: unknown): asserts value => {}
365+
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 127, 9))
366+
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 127, 20))
367+
>value : Symbol(value, Decl(assertionTypePredicates1.ts, 127, 20))
368+
369+
assert(typeof x === "string"); // Error
370+
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 127, 9))
371+
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 126, 13))
372+
373+
const a = [assert];
374+
>a : Symbol(a, Decl(assertionTypePredicates1.ts, 129, 9))
375+
>assert : Symbol(assert, Decl(assertionTypePredicates1.ts, 127, 9))
376+
377+
a[0](typeof x === "string"); // Error
378+
>a : Symbol(a, Decl(assertionTypePredicates1.ts, 129, 9))
379+
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 126, 13))
380+
381+
const t1 = new Test();
382+
>t1 : Symbol(t1, Decl(assertionTypePredicates1.ts, 131, 9))
383+
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
384+
385+
t1.assert(typeof x === "string"); // Error
386+
>t1.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
387+
>t1 : Symbol(t1, Decl(assertionTypePredicates1.ts, 131, 9))
388+
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
389+
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 126, 13))
390+
391+
const t2: Test = new Test();
392+
>t2 : Symbol(t2, Decl(assertionTypePredicates1.ts, 133, 9))
393+
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
394+
>Test : Symbol(Test, Decl(assertionTypePredicates1.ts, 76, 1))
395+
396+
t2.assert(typeof x === "string");
397+
>t2.assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
398+
>t2 : Symbol(t2, Decl(assertionTypePredicates1.ts, 133, 9))
399+
>assert : Symbol(Test.assert, Decl(assertionTypePredicates1.ts, 78, 12))
400+
>x : Symbol(x, Decl(assertionTypePredicates1.ts, 126, 13))
401+
}
402+

tests/baselines/reference/assertionTypePredicates1.types

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,66 @@ declare class Wat {
436436
>x : void
437437
}
438438

439+
function f20(x: unknown) {
440+
>f20 : (x: unknown) => void
441+
>x : unknown
442+
443+
const assert = (value: unknown): asserts value => {}
444+
>assert : (value: unknown) => asserts value
445+
>(value: unknown): asserts value => {} : (value: unknown) => asserts value
446+
>value : unknown
447+
448+
assert(typeof x === "string"); // Error
449+
>assert(typeof x === "string") : void
450+
>assert : (value: unknown) => asserts value
451+
>typeof x === "string" : boolean
452+
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
453+
>x : unknown
454+
>"string" : "string"
455+
456+
const a = [assert];
457+
>a : ((value: unknown) => asserts value)[]
458+
>[assert] : ((value: unknown) => asserts value)[]
459+
>assert : (value: unknown) => asserts value
460+
461+
a[0](typeof x === "string"); // Error
462+
>a[0](typeof x === "string") : void
463+
>a[0] : (value: unknown) => asserts value
464+
>a : ((value: unknown) => asserts value)[]
465+
>0 : 0
466+
>typeof x === "string" : boolean
467+
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
468+
>x : unknown
469+
>"string" : "string"
470+
471+
const t1 = new Test();
472+
>t1 : Test
473+
>new Test() : Test
474+
>Test : typeof Test
475+
476+
t1.assert(typeof x === "string"); // Error
477+
>t1.assert(typeof x === "string") : void
478+
>t1.assert : (value: unknown) => asserts value
479+
>t1 : Test
480+
>assert : (value: unknown) => asserts value
481+
>typeof x === "string" : boolean
482+
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
483+
>x : unknown
484+
>"string" : "string"
485+
486+
const t2: Test = new Test();
487+
>t2 : Test
488+
>new Test() : Test
489+
>Test : typeof Test
490+
491+
t2.assert(typeof x === "string");
492+
>t2.assert(typeof x === "string") : void
493+
>t2.assert : (value: unknown) => asserts value
494+
>t2 : Test
495+
>assert : (value: unknown) => asserts value
496+
>typeof x === "string" : boolean
497+
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
498+
>x : unknown
499+
>"string" : "string"
500+
}
501+

tests/baselines/reference/neverReturningFunctions1.errors.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(139,9): error TS
2121
tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(141,5): error TS7027: Unreachable code detected.
2222
tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(148,9): error TS7027: Unreachable code detected.
2323
tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(153,5): error TS7027: Unreachable code detected.
24+
tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(159,5): error TS2775: Control flow effects of calls to assertion and never-returning functions are reflected only when every variable or property referenced in the function expression is declared with an explicit type annotation.
25+
tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(160,5): error TS2776: Control flow effects of calls to assertion and never-returning functions are reflected only when the function expression is an identifier or qualified-name.
2426

2527

26-
==== tests/cases/conformance/controlFlow/neverReturningFunctions1.ts (23 errors) ====
28+
==== tests/cases/conformance/controlFlow/neverReturningFunctions1.ts (25 errors) ====
2729
function fail(message?: string): never {
2830
throw new Error(message);
2931
}
@@ -225,6 +227,17 @@ tests/cases/conformance/controlFlow/neverReturningFunctions1.ts(153,5): error TS
225227
!!! error TS7027: Unreachable code detected.
226228
}
227229

230+
function f43() {
231+
const fail = (): never => { throw new Error(); };
232+
const f = [fail];
233+
fail(); // Error
234+
~~~~
235+
!!! error TS2775: Control flow effects of calls to assertion and never-returning functions are reflected only when every variable or property referenced in the function expression is declared with an explicit type annotation.
236+
f[0](); // Error
237+
~~~~
238+
!!! error TS2776: Control flow effects of calls to assertion and never-returning functions are reflected only when the function expression is an identifier or qualified-name.
239+
}
240+
228241
// Repro from #33582
229242

230243
export interface Component<T extends object = any> {

tests/baselines/reference/neverReturningFunctions1.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ function f42(x: number) {
154154
x; // Unreachable
155155
}
156156

157+
function f43() {
158+
const fail = (): never => { throw new Error(); };
159+
const f = [fail];
160+
fail(); // Error
161+
f[0](); // Error
162+
}
163+
157164
// Repro from #33582
158165

159166
export interface Component<T extends object = any> {
@@ -375,6 +382,12 @@ function f42(x) {
375382
}
376383
x; // Unreachable
377384
}
385+
function f43() {
386+
var fail = function () { throw new Error(); };
387+
var f = [fail];
388+
fail(); // Error
389+
f[0](); // Error
390+
}
378391
var Component = registerComponent('test-component', {
379392
schema: {
380393
myProperty: {

0 commit comments

Comments
 (0)