mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-08 12:55:49 -05:00
add additional test for grammar and type checking
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
tests/cases/compiler/restParameterWithBindingPattern3.ts(1,16): error TS2322: Type '1' is not assignable to type 'string'.
|
||||
tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/restParameterWithBindingPattern3.ts (2 errors) ====
|
||||
function a(...[a = 1, b = true]: string[]) { }
|
||||
~
|
||||
!!! error TS2322: Type '1' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [restParameterWithBindingPattern3.ts]
|
||||
function a(...[a = 1, b = true]: string[]) { }
|
||||
|
||||
//// [restParameterWithBindingPattern3.js]
|
||||
function a() {
|
||||
var _a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var _b = _a[0], a = _b === void 0 ? 1 : _b, _c = _a[1], b = _c === void 0 ? true : _c;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern3.ts ===
|
||||
function a(...[a = 1, b = true]: string[]) { }
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern3.ts, 0, 15))
|
||||
>b : Symbol(b, Decl(restParameterWithBindingPattern3.ts, 0, 21))
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern3.ts ===
|
||||
function a(...[a = 1, b = true]: string[]) { }
|
||||
>a : (...[a, b]: string[]) => void
|
||||
>a : string
|
||||
>1 : 1
|
||||
>b : string
|
||||
>true : true
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/restParameterWithBindingPattern4.ts(1,23): error TS1186: A rest element cannot have an initializer.
|
||||
|
||||
|
||||
==== tests/cases/compiler/restParameterWithBindingPattern4.ts (1 errors) ====
|
||||
function a(...[...foo = []]: string[]) { }
|
||||
~
|
||||
!!! error TS1186: A rest element cannot have an initializer.
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [restParameterWithBindingPattern4.ts]
|
||||
function a(...[...foo = []]: string[]) { }
|
||||
|
||||
//// [restParameterWithBindingPattern4.js]
|
||||
function a() {
|
||||
var _a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var _b = _a.slice(0), foo = _b === void 0 ? [] : _b;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern4.ts ===
|
||||
function a(...[...foo = []]: string[]) { }
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern4.ts, 0, 0))
|
||||
>foo : Symbol(foo, Decl(restParameterWithBindingPattern4.ts, 0, 15))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern4.ts ===
|
||||
function a(...[...foo = []]: string[]) { }
|
||||
>a : (...[...foo]: string[]) => void
|
||||
>foo : string[]
|
||||
>[] : undefined[]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [restParameterWithBindingPattern5.ts]
|
||||
function a(...{0: a, length, 3: d}: [boolean, string, number]) { }
|
||||
|
||||
//// [restParameterWithBindingPattern5.js]
|
||||
function a() {
|
||||
var _a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var a = _a[0], length = _a.length, d = _a[3];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern5.ts ===
|
||||
function a(...{0: a, length, 3: d}: [boolean, string, number]) { }
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern5.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern5.ts, 0, 15))
|
||||
>length : Symbol(length, Decl(restParameterWithBindingPattern5.ts, 0, 20))
|
||||
>d : Symbol(d, Decl(restParameterWithBindingPattern5.ts, 0, 28))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern5.ts ===
|
||||
function a(...{0: a, length, 3: d}: [boolean, string, number]) { }
|
||||
>a : (__0_0: boolean, __0_1: string, __0_2: number) => void
|
||||
>a : boolean
|
||||
>length : 3
|
||||
>d : string | number | boolean
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/restParameterWithBindingPattern6.ts(1,23): error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/restParameterWithBindingPattern6.ts (1 errors) ====
|
||||
function a(...[a, , , d]: [boolean, string, number]) { }
|
||||
~
|
||||
!!! error TS2493: Tuple type '[boolean, string, number]' with length '3' cannot be assigned to tuple with length '4'.
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [restParameterWithBindingPattern6.ts]
|
||||
function a(...[a, , , d]: [boolean, string, number]) { }
|
||||
|
||||
//// [restParameterWithBindingPattern6.js]
|
||||
function a() {
|
||||
var _a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
_a[_i] = arguments[_i];
|
||||
}
|
||||
var a = _a[0], d = _a[3];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern6.ts ===
|
||||
function a(...[a, , , d]: [boolean, string, number]) { }
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern6.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(restParameterWithBindingPattern6.ts, 0, 15))
|
||||
>d : Symbol(d, Decl(restParameterWithBindingPattern6.ts, 0, 21))
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/restParameterWithBindingPattern6.ts ===
|
||||
function a(...[a, , , d]: [boolean, string, number]) { }
|
||||
>a : (__0_0: boolean, __0_1: string, __0_2: number) => void
|
||||
>a : boolean
|
||||
> : undefined
|
||||
> : undefined
|
||||
>d : any
|
||||
|
||||
1
tests/cases/compiler/restParameterWithBindingPattern3.ts
Normal file
1
tests/cases/compiler/restParameterWithBindingPattern3.ts
Normal file
@@ -0,0 +1 @@
|
||||
function a(...[a = 1, b = true]: string[]) { }
|
||||
1
tests/cases/compiler/restParameterWithBindingPattern4.ts
Normal file
1
tests/cases/compiler/restParameterWithBindingPattern4.ts
Normal file
@@ -0,0 +1 @@
|
||||
function a(...[...foo = []]: string[]) { }
|
||||
1
tests/cases/compiler/restParameterWithBindingPattern5.ts
Normal file
1
tests/cases/compiler/restParameterWithBindingPattern5.ts
Normal file
@@ -0,0 +1 @@
|
||||
function a(...{0: a, length, 3: d}: [boolean, string, number]) { }
|
||||
1
tests/cases/compiler/restParameterWithBindingPattern6.ts
Normal file
1
tests/cases/compiler/restParameterWithBindingPattern6.ts
Normal file
@@ -0,0 +1 @@
|
||||
function a(...[a, , , d]: [boolean, string, number]) { }
|
||||
Reference in New Issue
Block a user