A meta-ancestor type is an idiosyncrasies data structure. A meta-ancestor is an array with an explicit number of elements and each element type. The types of each element need not be exactly the same. TS can be defined using the same syntax as array literals. If you want to access a primitive element, you can still use array subscripts to access it.

const tuple:[number, string] = [18, 'leo'];
const age = tuple[0];
const name = tuple[1];
或者
const [age, name] = tuple
Copy the code

Primitives are used to return multiple return values in a function, and this type is becoming more common, as in React where hooks are used and ES2017 where object.entries () is used to retrieve an Object’s key-value array.

const [state, setState] = useState();
const obj = {
  foo: 123,
  bar: 456,
};
Object.entries(obj) // ['foo', 123], ['bar', 456]
Copy the code