I would recommend using TypeScript if you want to add type safety to your Javascript. Below is a function you may use though to ensure what you push is the correct type
const pushType = (arr, value, type) => { if (typeof value === type) { arr.push(value); }};pushType(['a', 'b'], 'c', 'string');