forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6995055
commit c2431ad
Showing
4 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/circularInferredTypeOfVariable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
})); |
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/circularInferredTypeOfVariable.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
}); |
47 changes: 47 additions & 0 deletions
47
tests/baselines/reference/circularInferredTypeOfVariable.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[] | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
}); |