mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Adding tests
This commit is contained in:
parent
5ab5338574
commit
5cb2b6afde
@ -0,0 +1,20 @@
|
||||
//// [declarationEmitFBoundedTypeParams.ts]
|
||||
|
||||
// Repro from #6040
|
||||
|
||||
function append<a, b extends a>(result: a[], value: b): a[] {
|
||||
result.push(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitFBoundedTypeParams.js]
|
||||
// Repro from #6040
|
||||
function append(result, value) {
|
||||
result.push(value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//// [declarationEmitFBoundedTypeParams.d.ts]
|
||||
declare function append<a, b extends a>(result: a[], value: b): a[];
|
||||
@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/declarationEmitFBoundedTypeParams.ts ===
|
||||
|
||||
// Repro from #6040
|
||||
|
||||
function append<a, b extends a>(result: a[], value: b): a[] {
|
||||
>append : Symbol(append, Decl(declarationEmitFBoundedTypeParams.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(declarationEmitFBoundedTypeParams.ts, 3, 16))
|
||||
>b : Symbol(b, Decl(declarationEmitFBoundedTypeParams.ts, 3, 18))
|
||||
>a : Symbol(a, Decl(declarationEmitFBoundedTypeParams.ts, 3, 16))
|
||||
>result : Symbol(result, Decl(declarationEmitFBoundedTypeParams.ts, 3, 32))
|
||||
>a : Symbol(a, Decl(declarationEmitFBoundedTypeParams.ts, 3, 16))
|
||||
>value : Symbol(value, Decl(declarationEmitFBoundedTypeParams.ts, 3, 44))
|
||||
>b : Symbol(b, Decl(declarationEmitFBoundedTypeParams.ts, 3, 18))
|
||||
>a : Symbol(a, Decl(declarationEmitFBoundedTypeParams.ts, 3, 16))
|
||||
|
||||
result.push(value);
|
||||
>result.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>result : Symbol(result, Decl(declarationEmitFBoundedTypeParams.ts, 3, 32))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>value : Symbol(value, Decl(declarationEmitFBoundedTypeParams.ts, 3, 44))
|
||||
|
||||
return result;
|
||||
>result : Symbol(result, Decl(declarationEmitFBoundedTypeParams.ts, 3, 32))
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/declarationEmitFBoundedTypeParams.ts ===
|
||||
|
||||
// Repro from #6040
|
||||
|
||||
function append<a, b extends a>(result: a[], value: b): a[] {
|
||||
>append : <a, b extends a>(result: a[], value: b) => a[]
|
||||
>a : a
|
||||
>b : b
|
||||
>a : a
|
||||
>result : a[]
|
||||
>a : a
|
||||
>value : b
|
||||
>b : b
|
||||
>a : a
|
||||
|
||||
result.push(value);
|
||||
>result.push(value) : number
|
||||
>result.push : (...items: a[]) => number
|
||||
>result : a[]
|
||||
>push : (...items: a[]) => number
|
||||
>value : b
|
||||
|
||||
return result;
|
||||
>result : a[]
|
||||
}
|
||||
|
||||
39
tests/baselines/reference/typeInferenceFBoundedTypeParams.js
Normal file
39
tests/baselines/reference/typeInferenceFBoundedTypeParams.js
Normal file
@ -0,0 +1,39 @@
|
||||
//// [typeInferenceFBoundedTypeParams.ts]
|
||||
// Example from #6037
|
||||
|
||||
function fold<a, r>(values: a[], result: r, fold: (result: r, value: a) => r): r {
|
||||
for (let value of values) {
|
||||
result = fold(result, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function append<a, b extends a>(values: a[], value: b): a[] {
|
||||
values.push(value);
|
||||
return values;
|
||||
}
|
||||
|
||||
fold(
|
||||
[1, 2, 3],
|
||||
[] as [string, string][],
|
||||
(result, value) => append(
|
||||
result,
|
||||
["", ""]
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
//// [typeInferenceFBoundedTypeParams.js]
|
||||
// Example from #6037
|
||||
function fold(values, result, fold) {
|
||||
for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
|
||||
var value = values_1[_i];
|
||||
result = fold(result, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function append(values, value) {
|
||||
values.push(value);
|
||||
return values;
|
||||
}
|
||||
fold([1, 2, 3], [], function (result, value) { return append(result, ["", ""]); });
|
||||
@ -0,0 +1,71 @@
|
||||
=== tests/cases/compiler/typeInferenceFBoundedTypeParams.ts ===
|
||||
// Example from #6037
|
||||
|
||||
function fold<a, r>(values: a[], result: r, fold: (result: r, value: a) => r): r {
|
||||
>fold : Symbol(fold, Decl(typeInferenceFBoundedTypeParams.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 2, 14))
|
||||
>r : Symbol(r, Decl(typeInferenceFBoundedTypeParams.ts, 2, 16))
|
||||
>values : Symbol(values, Decl(typeInferenceFBoundedTypeParams.ts, 2, 20))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 2, 14))
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 2, 32))
|
||||
>r : Symbol(r, Decl(typeInferenceFBoundedTypeParams.ts, 2, 16))
|
||||
>fold : Symbol(fold, Decl(typeInferenceFBoundedTypeParams.ts, 2, 43))
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 2, 51))
|
||||
>r : Symbol(r, Decl(typeInferenceFBoundedTypeParams.ts, 2, 16))
|
||||
>value : Symbol(value, Decl(typeInferenceFBoundedTypeParams.ts, 2, 61))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 2, 14))
|
||||
>r : Symbol(r, Decl(typeInferenceFBoundedTypeParams.ts, 2, 16))
|
||||
>r : Symbol(r, Decl(typeInferenceFBoundedTypeParams.ts, 2, 16))
|
||||
|
||||
for (let value of values) {
|
||||
>value : Symbol(value, Decl(typeInferenceFBoundedTypeParams.ts, 3, 12))
|
||||
>values : Symbol(values, Decl(typeInferenceFBoundedTypeParams.ts, 2, 20))
|
||||
|
||||
result = fold(result, value);
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 2, 32))
|
||||
>fold : Symbol(fold, Decl(typeInferenceFBoundedTypeParams.ts, 2, 43))
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 2, 32))
|
||||
>value : Symbol(value, Decl(typeInferenceFBoundedTypeParams.ts, 3, 12))
|
||||
}
|
||||
return result;
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 2, 32))
|
||||
}
|
||||
|
||||
function append<a, b extends a>(values: a[], value: b): a[] {
|
||||
>append : Symbol(append, Decl(typeInferenceFBoundedTypeParams.ts, 7, 1))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 9, 16))
|
||||
>b : Symbol(b, Decl(typeInferenceFBoundedTypeParams.ts, 9, 18))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 9, 16))
|
||||
>values : Symbol(values, Decl(typeInferenceFBoundedTypeParams.ts, 9, 32))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 9, 16))
|
||||
>value : Symbol(value, Decl(typeInferenceFBoundedTypeParams.ts, 9, 44))
|
||||
>b : Symbol(b, Decl(typeInferenceFBoundedTypeParams.ts, 9, 18))
|
||||
>a : Symbol(a, Decl(typeInferenceFBoundedTypeParams.ts, 9, 16))
|
||||
|
||||
values.push(value);
|
||||
>values.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>values : Symbol(values, Decl(typeInferenceFBoundedTypeParams.ts, 9, 32))
|
||||
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
|
||||
>value : Symbol(value, Decl(typeInferenceFBoundedTypeParams.ts, 9, 44))
|
||||
|
||||
return values;
|
||||
>values : Symbol(values, Decl(typeInferenceFBoundedTypeParams.ts, 9, 32))
|
||||
}
|
||||
|
||||
fold(
|
||||
>fold : Symbol(fold, Decl(typeInferenceFBoundedTypeParams.ts, 0, 0))
|
||||
|
||||
[1, 2, 3],
|
||||
[] as [string, string][],
|
||||
(result, value) => append(
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 17, 5))
|
||||
>value : Symbol(value, Decl(typeInferenceFBoundedTypeParams.ts, 17, 12))
|
||||
>append : Symbol(append, Decl(typeInferenceFBoundedTypeParams.ts, 7, 1))
|
||||
|
||||
result,
|
||||
>result : Symbol(result, Decl(typeInferenceFBoundedTypeParams.ts, 17, 5))
|
||||
|
||||
["", ""]
|
||||
)
|
||||
);
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
=== tests/cases/compiler/typeInferenceFBoundedTypeParams.ts ===
|
||||
// Example from #6037
|
||||
|
||||
function fold<a, r>(values: a[], result: r, fold: (result: r, value: a) => r): r {
|
||||
>fold : <a, r>(values: a[], result: r, fold: (result: r, value: a) => r) => r
|
||||
>a : a
|
||||
>r : r
|
||||
>values : a[]
|
||||
>a : a
|
||||
>result : r
|
||||
>r : r
|
||||
>fold : (result: r, value: a) => r
|
||||
>result : r
|
||||
>r : r
|
||||
>value : a
|
||||
>a : a
|
||||
>r : r
|
||||
>r : r
|
||||
|
||||
for (let value of values) {
|
||||
>value : a
|
||||
>values : a[]
|
||||
|
||||
result = fold(result, value);
|
||||
>result = fold(result, value) : r
|
||||
>result : r
|
||||
>fold(result, value) : r
|
||||
>fold : (result: r, value: a) => r
|
||||
>result : r
|
||||
>value : a
|
||||
}
|
||||
return result;
|
||||
>result : r
|
||||
}
|
||||
|
||||
function append<a, b extends a>(values: a[], value: b): a[] {
|
||||
>append : <a, b extends a>(values: a[], value: b) => a[]
|
||||
>a : a
|
||||
>b : b
|
||||
>a : a
|
||||
>values : a[]
|
||||
>a : a
|
||||
>value : b
|
||||
>b : b
|
||||
>a : a
|
||||
|
||||
values.push(value);
|
||||
>values.push(value) : number
|
||||
>values.push : (...items: a[]) => number
|
||||
>values : a[]
|
||||
>push : (...items: a[]) => number
|
||||
>value : b
|
||||
|
||||
return values;
|
||||
>values : a[]
|
||||
}
|
||||
|
||||
fold(
|
||||
>fold( [1, 2, 3], [] as [string, string][], (result, value) => append( result, ["", ""] )) : [string, string][]
|
||||
>fold : <a, r>(values: a[], result: r, fold: (result: r, value: a) => r) => r
|
||||
|
||||
[1, 2, 3],
|
||||
>[1, 2, 3] : number[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
|
||||
[] as [string, string][],
|
||||
>[] as [string, string][] : [string, string][]
|
||||
>[] : undefined[]
|
||||
|
||||
(result, value) => append(
|
||||
>(result, value) => append( result, ["", ""] ) : (result: [string, string][], value: number) => [string, string][]
|
||||
>result : [string, string][]
|
||||
>value : number
|
||||
>append( result, ["", ""] ) : [string, string][]
|
||||
>append : <a, b extends a>(values: a[], value: b) => a[]
|
||||
|
||||
result,
|
||||
>result : [string, string][]
|
||||
|
||||
["", ""]
|
||||
>["", ""] : [string, string]
|
||||
>"" : string
|
||||
>"" : string
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
// @declaration: true
|
||||
|
||||
// Repro from #6040
|
||||
|
||||
function append<a, b extends a>(result: a[], value: b): a[] {
|
||||
result.push(value);
|
||||
return result;
|
||||
}
|
||||
22
tests/cases/compiler/typeInferenceFBoundedTypeParams.ts
Normal file
22
tests/cases/compiler/typeInferenceFBoundedTypeParams.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// Example from #6037
|
||||
|
||||
function fold<a, r>(values: a[], result: r, fold: (result: r, value: a) => r): r {
|
||||
for (let value of values) {
|
||||
result = fold(result, value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function append<a, b extends a>(values: a[], value: b): a[] {
|
||||
values.push(value);
|
||||
return values;
|
||||
}
|
||||
|
||||
fold(
|
||||
[1, 2, 3],
|
||||
[] as [string, string][],
|
||||
(result, value) => append(
|
||||
result,
|
||||
["", ""]
|
||||
)
|
||||
);
|
||||
Loading…
x
Reference in New Issue
Block a user