mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Add regression test
This commit is contained in:
44
tests/baselines/reference/circularInferredTypeOfVariable.js
Normal file
44
tests/baselines/reference/circularInferredTypeOfVariable.js
Normal file
@@ -0,0 +1,44 @@
|
||||
//// [circularInferredTypeOfVariable.ts]
|
||||
|
||||
// Repro from #14428
|
||||
|
||||
(async () => {
|
||||
function foo(p: string[]): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
function bar(p: string[]): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
let a1: string[] | undefined = [];
|
||||
|
||||
while (true) {
|
||||
let a2 = foo(a1!);
|
||||
a1 = await bar(a2);
|
||||
}
|
||||
});
|
||||
|
||||
//// [circularInferredTypeOfVariable.js]
|
||||
// Repro from #14428
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
(() => __awaiter(this, void 0, void 0, function* () {
|
||||
function foo(p) {
|
||||
return [];
|
||||
}
|
||||
function bar(p) {
|
||||
return [];
|
||||
}
|
||||
let a1 = [];
|
||||
while (true) {
|
||||
let a2 = foo(a1);
|
||||
a1 = yield bar(a2);
|
||||
}
|
||||
}));
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/compiler/circularInferredTypeOfVariable.ts ===
|
||||
|
||||
// Repro from #14428
|
||||
|
||||
(async () => {
|
||||
function foo(p: string[]): string[] {
|
||||
>foo : Symbol(foo, Decl(circularInferredTypeOfVariable.ts, 3, 14))
|
||||
>p : Symbol(p, Decl(circularInferredTypeOfVariable.ts, 4, 17))
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function bar(p: string[]): string[] {
|
||||
>bar : Symbol(bar, Decl(circularInferredTypeOfVariable.ts, 6, 5))
|
||||
>p : Symbol(p, Decl(circularInferredTypeOfVariable.ts, 8, 17))
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
let a1: string[] | undefined = [];
|
||||
>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7))
|
||||
|
||||
while (true) {
|
||||
let a2 = foo(a1!);
|
||||
>a2 : Symbol(a2, Decl(circularInferredTypeOfVariable.ts, 15, 11))
|
||||
>foo : Symbol(foo, Decl(circularInferredTypeOfVariable.ts, 3, 14))
|
||||
>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7))
|
||||
|
||||
a1 = await bar(a2);
|
||||
>a1 : Symbol(a1, Decl(circularInferredTypeOfVariable.ts, 12, 7))
|
||||
>bar : Symbol(bar, Decl(circularInferredTypeOfVariable.ts, 6, 5))
|
||||
>a2 : Symbol(a2, Decl(circularInferredTypeOfVariable.ts, 15, 11))
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/circularInferredTypeOfVariable.ts ===
|
||||
|
||||
// Repro from #14428
|
||||
|
||||
(async () => {
|
||||
>(async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); }}) : () => Promise<never>
|
||||
>async () => { function foo(p: string[]): string[] { return []; } function bar(p: string[]): string[] { return []; } let a1: string[] | undefined = []; while (true) { let a2 = foo(a1!); a1 = await bar(a2); }} : () => Promise<never>
|
||||
|
||||
function foo(p: string[]): string[] {
|
||||
>foo : (p: string[]) => string[]
|
||||
>p : string[]
|
||||
|
||||
return [];
|
||||
>[] : undefined[]
|
||||
}
|
||||
|
||||
function bar(p: string[]): string[] {
|
||||
>bar : (p: string[]) => string[]
|
||||
>p : string[]
|
||||
|
||||
return [];
|
||||
>[] : undefined[]
|
||||
}
|
||||
|
||||
let a1: string[] | undefined = [];
|
||||
>a1 : string[]
|
||||
>[] : undefined[]
|
||||
|
||||
while (true) {
|
||||
>true : true
|
||||
|
||||
let a2 = foo(a1!);
|
||||
>a2 : string[]
|
||||
>foo(a1!) : string[]
|
||||
>foo : (p: string[]) => string[]
|
||||
>a1! : string[]
|
||||
>a1 : string[]
|
||||
|
||||
a1 = await bar(a2);
|
||||
>a1 = await bar(a2) : string[]
|
||||
>a1 : string[]
|
||||
>await bar(a2) : string[]
|
||||
>bar(a2) : string[]
|
||||
>bar : (p: string[]) => string[]
|
||||
>a2 : string[]
|
||||
}
|
||||
});
|
||||
20
tests/cases/compiler/circularInferredTypeOfVariable.ts
Normal file
20
tests/cases/compiler/circularInferredTypeOfVariable.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// @target: es6
|
||||
|
||||
// Repro from #14428
|
||||
|
||||
(async () => {
|
||||
function foo(p: string[]): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
function bar(p: string[]): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
let a1: string[] | undefined = [];
|
||||
|
||||
while (true) {
|
||||
let a2 = foo(a1!);
|
||||
a1 = await bar(a2);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user