mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Accept new baselines
This commit is contained in:
@@ -58,4 +58,21 @@ tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference
|
||||
|
||||
declare function bar<T>(x: T, y: string | T): T;
|
||||
const y = bar(1, 2);
|
||||
|
||||
// Repro from #32752
|
||||
|
||||
const containsPromises: unique symbol = Symbol();
|
||||
|
||||
type DeepPromised<T> =
|
||||
{ [containsPromises]?: true } &
|
||||
{ [TKey in keyof T]: T[TKey] | DeepPromised<T[TKey]> | Promise<DeepPromised<T[TKey]>> };
|
||||
|
||||
async function fun<T>(deepPromised: DeepPromised<T>) {
|
||||
const deepPromisedWithIndexer: DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised;
|
||||
for (const value of Object.values(deepPromisedWithIndexer)) {
|
||||
const awaitedValue = await value;
|
||||
if (awaitedValue)
|
||||
await fun(awaitedValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,29 +50,54 @@ foo(x);
|
||||
|
||||
declare function bar<T>(x: T, y: string | T): T;
|
||||
const y = bar(1, 2);
|
||||
|
||||
// Repro from #32752
|
||||
|
||||
const containsPromises: unique symbol = Symbol();
|
||||
|
||||
type DeepPromised<T> =
|
||||
{ [containsPromises]?: true } &
|
||||
{ [TKey in keyof T]: T[TKey] | DeepPromised<T[TKey]> | Promise<DeepPromised<T[TKey]>> };
|
||||
|
||||
async function fun<T>(deepPromised: DeepPromised<T>) {
|
||||
const deepPromisedWithIndexer: DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised;
|
||||
for (const value of Object.values(deepPromisedWithIndexer)) {
|
||||
const awaitedValue = await value;
|
||||
if (awaitedValue)
|
||||
await fun(awaitedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [unionTypeInference.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var a1 = f1(1, 2); // 1 | 2
|
||||
var a2 = f1(1, "hello"); // 1
|
||||
var a3 = f1(1, sn); // number
|
||||
var a4 = f1(undefined, "abc"); // undefined
|
||||
var a5 = f1("foo", "bar"); // "foo"
|
||||
var a6 = f1(true, false); // boolean
|
||||
var a7 = f1("hello", 1); // Error
|
||||
const a1 = f1(1, 2); // 1 | 2
|
||||
const a2 = f1(1, "hello"); // 1
|
||||
const a3 = f1(1, sn); // number
|
||||
const a4 = f1(undefined, "abc"); // undefined
|
||||
const a5 = f1("foo", "bar"); // "foo"
|
||||
const a6 = f1(true, false); // boolean
|
||||
const a7 = f1("hello", 1); // Error
|
||||
var b1 = f2(["string", true]); // boolean
|
||||
var c1 = f3(5); // 5
|
||||
var c2 = f3(sn); // number
|
||||
var c3 = f3(true); // true
|
||||
var c4 = f3(b); // true
|
||||
var c5 = f3("abc"); // never
|
||||
var d1 = f4("abc");
|
||||
var d2 = f4(s);
|
||||
var d3 = f4(42); // Error
|
||||
const c1 = f3(5); // 5
|
||||
const c2 = f3(sn); // number
|
||||
const c3 = f3(true); // true
|
||||
const c4 = f3(b); // true
|
||||
const c5 = f3("abc"); // never
|
||||
const d1 = f4("abc");
|
||||
const d2 = f4(s);
|
||||
const d3 = f4(42); // Error
|
||||
function qux(p1, p2) {
|
||||
p1 = p2;
|
||||
}
|
||||
foo(x);
|
||||
var y = bar(1, 2);
|
||||
const y = bar(1, 2);
|
||||
// Repro from #32752
|
||||
const containsPromises = Symbol();
|
||||
async function fun(deepPromised) {
|
||||
const deepPromisedWithIndexer = deepPromised;
|
||||
for (const value of Object.values(deepPromisedWithIndexer)) {
|
||||
const awaitedValue = await value;
|
||||
if (awaitedValue)
|
||||
await fun(awaitedValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ declare function foo<T>(x: T | Promise<T>): void;
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
|
||||
>x : Symbol(x, Decl(unionTypeInference.ts, 45, 24))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 45, 21))
|
||||
|
||||
declare let x: false | Promise<true>;
|
||||
>x : Symbol(x, Decl(unionTypeInference.ts, 46, 11))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
|
||||
|
||||
foo(x);
|
||||
>foo : Symbol(foo, Decl(unionTypeInference.ts, 41, 1))
|
||||
@@ -187,3 +187,63 @@ const y = bar(1, 2);
|
||||
>y : Symbol(y, Decl(unionTypeInference.ts, 50, 5))
|
||||
>bar : Symbol(bar, Decl(unionTypeInference.ts, 47, 7))
|
||||
|
||||
// Repro from #32752
|
||||
|
||||
const containsPromises: unique symbol = Symbol();
|
||||
>containsPromises : Symbol(containsPromises, Decl(unionTypeInference.ts, 54, 5))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --))
|
||||
|
||||
type DeepPromised<T> =
|
||||
>DeepPromised : Symbol(DeepPromised, Decl(unionTypeInference.ts, 54, 49))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 56, 18))
|
||||
|
||||
{ [containsPromises]?: true } &
|
||||
>[containsPromises] : Symbol([containsPromises], Decl(unionTypeInference.ts, 57, 5))
|
||||
>containsPromises : Symbol(containsPromises, Decl(unionTypeInference.ts, 54, 5))
|
||||
|
||||
{ [TKey in keyof T]: T[TKey] | DeepPromised<T[TKey]> | Promise<DeepPromised<T[TKey]>> };
|
||||
>TKey : Symbol(TKey, Decl(unionTypeInference.ts, 58, 7))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 56, 18))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 56, 18))
|
||||
>TKey : Symbol(TKey, Decl(unionTypeInference.ts, 58, 7))
|
||||
>DeepPromised : Symbol(DeepPromised, Decl(unionTypeInference.ts, 54, 49))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 56, 18))
|
||||
>TKey : Symbol(TKey, Decl(unionTypeInference.ts, 58, 7))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
|
||||
>DeepPromised : Symbol(DeepPromised, Decl(unionTypeInference.ts, 54, 49))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 56, 18))
|
||||
>TKey : Symbol(TKey, Decl(unionTypeInference.ts, 58, 7))
|
||||
|
||||
async function fun<T>(deepPromised: DeepPromised<T>) {
|
||||
>fun : Symbol(fun, Decl(unionTypeInference.ts, 58, 92))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 60, 19))
|
||||
>deepPromised : Symbol(deepPromised, Decl(unionTypeInference.ts, 60, 22))
|
||||
>DeepPromised : Symbol(DeepPromised, Decl(unionTypeInference.ts, 54, 49))
|
||||
>T : Symbol(T, Decl(unionTypeInference.ts, 60, 19))
|
||||
|
||||
const deepPromisedWithIndexer: DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised;
|
||||
>deepPromisedWithIndexer : Symbol(deepPromisedWithIndexer, Decl(unionTypeInference.ts, 61, 9))
|
||||
>DeepPromised : Symbol(DeepPromised, Decl(unionTypeInference.ts, 54, 49))
|
||||
>name : Symbol(name, Decl(unionTypeInference.ts, 61, 51))
|
||||
>deepPromised : Symbol(deepPromised, Decl(unionTypeInference.ts, 60, 22))
|
||||
|
||||
for (const value of Object.values(deepPromisedWithIndexer)) {
|
||||
>value : Symbol(value, Decl(unionTypeInference.ts, 62, 14))
|
||||
>Object.values : Symbol(ObjectConstructor.values, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --))
|
||||
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>values : Symbol(ObjectConstructor.values, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --))
|
||||
>deepPromisedWithIndexer : Symbol(deepPromisedWithIndexer, Decl(unionTypeInference.ts, 61, 9))
|
||||
|
||||
const awaitedValue = await value;
|
||||
>awaitedValue : Symbol(awaitedValue, Decl(unionTypeInference.ts, 63, 13))
|
||||
>value : Symbol(value, Decl(unionTypeInference.ts, 62, 14))
|
||||
|
||||
if (awaitedValue)
|
||||
>awaitedValue : Symbol(awaitedValue, Decl(unionTypeInference.ts, 63, 13))
|
||||
|
||||
await fun(awaitedValue);
|
||||
>fun : Symbol(fun, Decl(unionTypeInference.ts, 58, 92))
|
||||
>awaitedValue : Symbol(awaitedValue, Decl(unionTypeInference.ts, 63, 13))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,3 +185,54 @@ const y = bar(1, 2);
|
||||
>1 : 1
|
||||
>2 : 2
|
||||
|
||||
// Repro from #32752
|
||||
|
||||
const containsPromises: unique symbol = Symbol();
|
||||
>containsPromises : unique symbol
|
||||
>Symbol() : unique symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
type DeepPromised<T> =
|
||||
>DeepPromised : DeepPromised<T>
|
||||
|
||||
{ [containsPromises]?: true } &
|
||||
>[containsPromises] : true | undefined
|
||||
>containsPromises : unique symbol
|
||||
>true : true
|
||||
|
||||
{ [TKey in keyof T]: T[TKey] | DeepPromised<T[TKey]> | Promise<DeepPromised<T[TKey]>> };
|
||||
|
||||
async function fun<T>(deepPromised: DeepPromised<T>) {
|
||||
>fun : <T>(deepPromised: DeepPromised<T>) => Promise<void>
|
||||
>deepPromised : DeepPromised<T>
|
||||
|
||||
const deepPromisedWithIndexer: DeepPromised<{ [name: string]: {} | null | undefined }> = deepPromised;
|
||||
>deepPromisedWithIndexer : DeepPromised<{ [name: string]: {} | null | undefined; }>
|
||||
>name : string
|
||||
>null : null
|
||||
>deepPromised : DeepPromised<T>
|
||||
|
||||
for (const value of Object.values(deepPromisedWithIndexer)) {
|
||||
>value : {} | ({ [containsPromises]?: true | undefined; } & {}) | Promise<{ [containsPromises]?: true | undefined; } & {}> | null | undefined
|
||||
>Object.values(deepPromisedWithIndexer) : ({} | ({ [containsPromises]?: true | undefined; } & {}) | Promise<{ [containsPromises]?: true | undefined; } & {}> | null | undefined)[]
|
||||
>Object.values : { <T>(o: { [s: string]: T; } | ArrayLike<T>): T[]; (o: {}): any[]; }
|
||||
>Object : ObjectConstructor
|
||||
>values : { <T>(o: { [s: string]: T; } | ArrayLike<T>): T[]; (o: {}): any[]; }
|
||||
>deepPromisedWithIndexer : DeepPromised<{ [name: string]: {} | null | undefined; }>
|
||||
|
||||
const awaitedValue = await value;
|
||||
>awaitedValue : {} | ({ [containsPromises]?: true | undefined; } & {}) | null | undefined
|
||||
>await value : {} | ({ [containsPromises]?: true | undefined; } & {}) | null | undefined
|
||||
>value : {} | ({ [containsPromises]?: true | undefined; } & {}) | Promise<{ [containsPromises]?: true | undefined; } & {}> | null | undefined
|
||||
|
||||
if (awaitedValue)
|
||||
>awaitedValue : {} | ({ [containsPromises]?: true | undefined; } & {}) | null | undefined
|
||||
|
||||
await fun(awaitedValue);
|
||||
>await fun(awaitedValue) : void
|
||||
>fun(awaitedValue) : Promise<void>
|
||||
>fun : <T>(deepPromised: DeepPromised<T>) => Promise<void>
|
||||
>awaitedValue : {} | ({ [containsPromises]?: true | undefined; } & {})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user