add test for generic spreads in a tuple

This commit is contained in:
Erik Krogh Kristensen
2020-08-11 10:18:06 +02:00
parent 08c017eb09
commit b602a36a24
2 changed files with 12 additions and 0 deletions

View File

@@ -108,6 +108,7 @@ test_VariableTypes
| tst.ts:142:17:142:25 | condition | condition | tst.ts:142:28:142:30 | any |
| tst.ts:142:33:142:35 | msg | msg | tst.ts:142:39:142:44 | string |
| tst.ts:148:25:148:27 | val | val | tst.ts:148:30:148:32 | any |
| tst.ts:157:32:157:34 | arr | arr | tst.ts:157:37:157:56 | readonly [any, ...T] |
test_QualifiedTypeAccess
| tst.ts:63:19:63:21 | N.I | tst.ts:63:19:63:19 | N | tst.ts:63:21:63:21 | I |
| tst.ts:64:20:64:24 | N.M.I | tst.ts:64:20:64:22 | N.M | tst.ts:64:24:64:24 | I |
@@ -198,6 +199,8 @@ test_TupleTypeExpr
| tst.ts:136:39:136:68 | [number ... mber[]] | 0 | 3 | tst.ts:136:40:136:45 | number |
| tst.ts:136:39:136:68 | [number ... mber[]] | 1 | 3 | tst.ts:136:48:136:54 | string? |
| tst.ts:136:39:136:68 | [number ... mber[]] | 2 | 3 | tst.ts:136:57:136:67 | ...number[] |
| tst.ts:157:46:157:56 | [any, ...T] | 0 | 2 | tst.ts:157:47:157:49 | any |
| tst.ts:157:46:157:56 | [any, ...T] | 1 | 2 | tst.ts:157:52:157:55 | ...T |
test_FieldTypes
| tst.ts:15:3:15:22 | numberField: number; | tst.ts:15:16:15:21 | number |
| tst.ts:16:3:16:22 | stringField: string; | tst.ts:16:16:16:21 | string |
@@ -219,6 +222,7 @@ test_ArrayTypeExpr
| tst.ts:81:27:81:34 | string[] | tst.ts:81:27:81:32 | string |
| tst.ts:135:39:135:46 | string[] | tst.ts:135:39:135:44 | string |
| tst.ts:136:60:136:67 | number[] | tst.ts:136:60:136:65 | number |
| tst.ts:157:25:157:29 | any[] | tst.ts:157:25:157:27 | any |
test_TypeAccessHelpers
| tst.ts:65:18:65:24 | Generic | 1 | 0 | tst.ts:65:26:65:31 | number |
| tst.ts:66:18:66:32 | N.InnerGeneric1 | 1 | 0 | tst.ts:66:34:66:39 | number |

View File

@@ -150,3 +150,11 @@ function assertIsString(val: any): asserts val is string {
throw new AssertionError("Not a string!");
}
}
// TypeScript 4.0
// spreads in tuple type syntax can now be generic
function tail<T extends any[]>(arr: readonly [any, ...T]) {
const [_ignored, ...rest] = arr;
return rest;
}