I am encountering an issue where I am unable to assign a specific object to a variable even though the type is correct. I have created a class named Article with various properties.
export class Article {
skuNumber: number;
condition: string;
eanCode: number;
manufacturer: string;
manufacturerIdentifier: string;
title: string;
description: string;
quantity: number;
weight: number;
width: number;
height: number;
depth: number
constructor(
skuNumber: number,
condition: string,
eanCode: number,
manufacturer: string,
manufacturerIdentifier: string,
title: string,
description: string,
quantity: number,
weight: number,
width: number,
height: number,
depth: number
) {
// Assigning values to class properties within the constructor
}
}
In a separate file, I have filled an Array with sample data of Article objects:
import { Article } from "./article";
export const ARTICLES: Array<Article> = [
// Sample Article objects with different details
];
Now, when trying to search for a specific object within this Array using filter, I encounter the error message related to missing properties in the 'Article' type.
let article: Article = this.articles.filter(article => article.eanCode === eanCodeOfNeededArticle);
If anyone has suggestions on how to resolve this issue, I would greatly appreciate the assistance. Thank you!