Skip to content

Commit 6d67054

Browse files
committed
Accept new baselines
1 parent 5524a61 commit 6d67054

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [unionReductionMutualSubtypes.ts]
2+
// Repro from #35414
3+
4+
interface ReturnVal {
5+
something(): void;
6+
}
7+
8+
const k: ReturnVal = { something() { } }
9+
10+
declare const val: ReturnVal;
11+
function run(options: { something?(b?: string): void }) {
12+
const something = options.something ?? val.something;
13+
something('');
14+
}
15+
16+
17+
//// [unionReductionMutualSubtypes.js]
18+
"use strict";
19+
// Repro from #35414
20+
var k = { something: function () { } };
21+
function run(options) {
22+
var _a;
23+
var something = (_a = options.something) !== null && _a !== void 0 ? _a : val.something;
24+
something('');
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
=== tests/cases/compiler/unionReductionMutualSubtypes.ts ===
2+
// Repro from #35414
3+
4+
interface ReturnVal {
5+
>ReturnVal : Symbol(ReturnVal, Decl(unionReductionMutualSubtypes.ts, 0, 0))
6+
7+
something(): void;
8+
>something : Symbol(ReturnVal.something, Decl(unionReductionMutualSubtypes.ts, 2, 21))
9+
}
10+
11+
const k: ReturnVal = { something() { } }
12+
>k : Symbol(k, Decl(unionReductionMutualSubtypes.ts, 6, 5))
13+
>ReturnVal : Symbol(ReturnVal, Decl(unionReductionMutualSubtypes.ts, 0, 0))
14+
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 6, 22))
15+
16+
declare const val: ReturnVal;
17+
>val : Symbol(val, Decl(unionReductionMutualSubtypes.ts, 8, 13))
18+
>ReturnVal : Symbol(ReturnVal, Decl(unionReductionMutualSubtypes.ts, 0, 0))
19+
20+
function run(options: { something?(b?: string): void }) {
21+
>run : Symbol(run, Decl(unionReductionMutualSubtypes.ts, 8, 29))
22+
>options : Symbol(options, Decl(unionReductionMutualSubtypes.ts, 9, 13))
23+
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 9, 23))
24+
>b : Symbol(b, Decl(unionReductionMutualSubtypes.ts, 9, 35))
25+
26+
const something = options.something ?? val.something;
27+
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 10, 9))
28+
>options.something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 9, 23))
29+
>options : Symbol(options, Decl(unionReductionMutualSubtypes.ts, 9, 13))
30+
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 9, 23))
31+
>val.something : Symbol(ReturnVal.something, Decl(unionReductionMutualSubtypes.ts, 2, 21))
32+
>val : Symbol(val, Decl(unionReductionMutualSubtypes.ts, 8, 13))
33+
>something : Symbol(ReturnVal.something, Decl(unionReductionMutualSubtypes.ts, 2, 21))
34+
35+
something('');
36+
>something : Symbol(something, Decl(unionReductionMutualSubtypes.ts, 10, 9))
37+
}
38+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
=== tests/cases/compiler/unionReductionMutualSubtypes.ts ===
2+
// Repro from #35414
3+
4+
interface ReturnVal {
5+
something(): void;
6+
>something : () => void
7+
}
8+
9+
const k: ReturnVal = { something() { } }
10+
>k : ReturnVal
11+
>{ something() { } } : { something(): void; }
12+
>something : () => void
13+
14+
declare const val: ReturnVal;
15+
>val : ReturnVal
16+
17+
function run(options: { something?(b?: string): void }) {
18+
>run : (options: { something?(b?: string | undefined): void; }) => void
19+
>options : { something?(b?: string | undefined): void; }
20+
>something : ((b?: string | undefined) => void) | undefined
21+
>b : string | undefined
22+
23+
const something = options.something ?? val.something;
24+
>something : (b?: string | undefined) => void
25+
>options.something ?? val.something : (b?: string | undefined) => void
26+
>options.something : ((b?: string | undefined) => void) | undefined
27+
>options : { something?(b?: string | undefined): void; }
28+
>something : ((b?: string | undefined) => void) | undefined
29+
>val.something : () => void
30+
>val : ReturnVal
31+
>something : () => void
32+
33+
something('');
34+
>something('') : void
35+
>something : (b?: string | undefined) => void
36+
>'' : ""
37+
}
38+

0 commit comments

Comments
 (0)