Stack Exchange
Property does not exist on type 'never'. in a function
    //the error is 
    //(Property 'productId' does not exist on type 'never'.) 
    //and 
    //(Property 'qty' //does not exist on type 'never'.)
    
    
import { Component, OnInit } from '@angular/core';
import { MessengerService } from 'src/app/services/messenger.service';
import { Product } from 'src/app/models/product';

@Component({
  selector: 'app-cart',
  templateUrl: './cart.component.html',
  styleUrls: ['./cart.component.css']
})
export class CartComponent implements OnInit {

  cartItems = [];
  cartTotal = 0
  
   
  
  constructor(private msg: MessengerService) { }

  ngOnInit() {
    this.msg.getMsg().subscribe((product:any = Product) => {
      this.addProductToCart(product)
      
    })
  }

addProductToCart(product: Product) {
  let productExists = false
  

  for (let i in this.cartItems) {
    if (this.cartItems[i].productId === product.id) {
      this.cartItems[i].qty++
      productExists = true
      break;
    }
  }

the problem is in this fucntion the productId and the qty gives error
//(Property 'productId' does not exist on type 'never'.)
//and
//(Property 'qty' //does not exist on type 'never'.)

Provide more details, show where you instantiate the cartItems array, and do some research effort before submitting a question

When you declare an empty array in typescript, default type of it is never[]. Try decalare type:
cartItems: cartItemType = [];


@braaIgb cool, you can select 'best answer' to indicate that problem has been solved
