Compile error trying to add an object to a Typescript array

I have the following array in Typescript:

const items = [
  { data1: 'zxcv', data2: '4444', data3: 'asdf'},
  { data1: 'rtyu', data2: '2222', data3: 'lkjh'}];

I’m trying to add to it, and I’ve tried this:

const add = { data1: 'sxsx', data2: '1111', data3: 'fgtr'};
items.push(add);

The error I get is:

Argument of type ‘{ data1: string; data2: string; data3: string; }’ is not assignable to parameter of type ‘{ data2: number; data1: string; data3: string; }’. Types of property ‘data2’ are incompatible. Type ‘string’ is not assignable to type ‘number’

I’ve tried doing the following, but it seems to make no difference:

const add: { 
        data1: string, 
        data2: string, 
        data3: string } 
        = { data1: 'sxsx', data2: '1111', data3: 'fgtr'};
items.push(add);

Answer

Although I dont see anything with your code, you can create an interface

interface Item {
   data1: string;
   data2: string;
   data3: string;
}

and then you can use it like

const items: Item[] = [
   { data1: 'zxcv', data2: '4444', data3: 'asdf'},
   { data1: 'rtyu', data2: '2222', data3: 'lkjh'}
];

const add: Item = { data1: 'sxsx', data2: '1111', data3: 'fgtr'};
items.push(add);