Property 'id' does not exist on type 'string'


#1

Hi all,

Problem
It’s saying does not exist on type ‘string’. But it’s an Object and a Array.

Error message

Variables
The variables with o as prefix are objects.
The variables with a as prefix are arrays.

Console.log of the variables

Code

updateRooms()
    {
        let oUserProjectsData = this.auth.getUserInfo();
        let oCurrentProject = this.oProject;
        let aProjects : any = oUserProjectsData.projects;

        for (let i = 0; i < aProjects.length; i++)
        {
            if(aProjects[i]['id'] == oCurrentProject.id)
            {
                // Set hier het actieve project
                this.oProject = aProjects[i];
            }
        }

        this.initializeItems();
    }

Hope someone can help me out.
Can’t spot the problem.


#2

Solved with:

if(parseInt(aProjects[i]['id']) == oCurrentProject.id)