Javascript TypeScript:具有不同元素类型的concat数组

Javascript TypeScript:具有不同元素类型的concat数组,javascript,arrays,typescript,Javascript,Arrays,Typescript,这是有效的 let head = [["title", "value"], ["a", 1]]; let tail = [["b", 2], ["c", 3]]; let all = head.concat (tail); 好的结果是 [["title", "value"], ["a", 1], ["b", 2], ["c", 3]] 但我需要的是这个,而这不起作用 let head = [["title", "value"]]; let tail = [["a", 1], ["b", 2

这是有效的

let head = [["title", "value"], ["a", 1]];
let tail = [["b", 2], ["c", 3]];

let all = head.concat (tail);
好的结果是

[["title", "value"], ["a", 1], ["b", 2], ["c", 3]]
但我需要的是这个,而这不起作用

let head = [["title", "value"]];
let tail = [["a", 1], ["b", 2], ["c", 3]];

let all = head.concat (tail);
错误:

Argument of type '(string | number)[][]' is not assignable to parameter 
of type 'string[] | string[][]'. 
 Type '(string | number)[][]' is not assignable to type 'string[][]'. 
  Type '(string | number)[]' is not assignable to type 'string[]'. 
   Type 'string | number' is not assignable to type 'string'. 
    Type 'number' is not assignable to type 'string'.
如果我将尾部的数字转换成字符串,它就会起作用——因为某些原因,我无法做到这一点

那么我怎样才能让它工作


谢谢

您可以这样声明
头的类型:

let head: [Array<string|number>] = [["title", "value"]];
let head:[Array]=[[“title”,“value”];
这将消除错误并保持类型安全