I cut and pasted the posted code into a minimal VS2019 console application . There were no Intellisense errors in the display and no errors when building -
Have you tried right clicking the project node in solution explorer and selecting "Rescan Solution"? If you hover the mouse over the red squiggles is an error displayed?
Another place to look is in the Error List when set to display Build+Intellisense messages.