UnityEngine.UI is not showing up?

I have a script that needs to access Image.fillAmount but this is only in UnityEngine.UI which doesn’t work even though I have Unity UI package installed.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;

public class BattleHud : MonoBehaviour
{
    public TextMeshProUGUI unitName;
    public TextMeshProUGUI level;
    public Image healthBar;
    
    void Awake()
    {

    }
    public void SetHUD(Unit unit)
    {
        unitName.text = unit.unitName;
        level.text = "Lvl. "+unit.level.ToString();
        healthBar.fillAmount = unit.curHealth/unit.maxHealth;
    }
    public void SetHP(Unit unit)
    {
        healthBar.fillAmount = unit.curHealth/unit.maxHealth;
    }
}

Actually using a slider instead fixes the issue for anyone with the same problem although a red line does still appear under the using UnityEngine.UI in vsc.