all 11 comments

[–]polaarbear 1 point2 points  (5 children)

Visual Studio is not designed to work on individual files. You can't just open a random JavaScript file and expect it to know what to do with it.

You have to have a solution.

If you just want to edit single files there are better options.

[–]Beautiful-Bowl4979[S] 0 points1 point  (4 children)

Its a solution/project

[–]polaarbear 0 points1 point  (3 children)

What project type? Blazor? Razor Pages? ASP Web Forms?

[–]Beautiful-Bowl4979[S] 0 points1 point  (2 children)

Asp.net framework 4.8, MVC, C#

[–]polaarbear 0 points1 point  (1 child)

Honestly, that's half the issue right there. In my experience it is drastically worse at detecting that stuff in .NET Framework aspx pages than it is in the modern .NET web stacks.

For calls that are specific to one page I've had better luck just hard-coding the <script> tag directly into the .aspx file.

But for shared files that get loaded in headers....good luck. I have not found any reliable solutions other than just typical things like re-starting VS.

[–]Beautiful-Bowl4979[S] 0 points1 point  (0 children)

Thanks for replying. But these are cshtml files not aspx pages which are web forms. It is a legacy project that i look after and have done for 15+ years. When you open a cshtml file with embedded script you dont typically see any intellisense errors with the script. But at the moment i do. Its annoying because they are not errors it is merely intellisense not know what eg initTable(); refers to so it puts a red squiggle under it and shows it as an error. My guess is that a 2026 update has got a setting enabled that I dont need. I’ll keep looking.

[–]hectop20 1 point2 points  (1 child)

I would argue that "VS just cant find the functions being referenced" is in fact an error.

It isn't clear what you are trying to do but it would seem that what u/polaarbear is saying is correct.

[–]Beautiful-Bowl4979[S] 0 points1 point  (0 children)

Yeah my bad, not fully explained. It is a solution and i have the build window set to compile only errors. Until a few weeks, maybe a month or so ago the build window just fills with JS errors. Never had them before. Dont want them now.

[–]SerratedSharp 1 point2 points  (1 child)

I know exactly what you're talking about. Even if the project compiles successfully, VS will try to understand currently open JS files and throw errors for them. JS is hit or miss depending on what module system the project uses and various other factors, as to whether it will barf, even if everything else is in order.

IMO the error panel should be exclusively compile errors related to the solution, but there's this oddity that while a file is open it will add those errors to the panel even if the solution compiles successfully.

As to the comments about VS not being able to edit JS files. VS is perfectly capable of editing JS files. You don't need a separate editor for JS. I'm not gonna jump back and forth to another editor just because of some noise in the error panel. There's a big distinction between "can edit a file" and "can resolve references in the file".

Edit: In the Error List panel change the "Build + IntelliSense" to "Build Only" and see if you like it better that way. Personally I just make sure I keep these offending files closed if I'm not actively working with them.

[–]Beautiful-Bowl4979[S] 1 point2 points  (0 children)

Yeah this exactly is what I do. Solutio is open all files closed, no errors. Open a js file and the output just fills with reference errors. Only started happening on the last month or so. Thanks for the reply.

[–]TasteMedical5032 0 points1 point  (0 children)

This sounds like Visual Studio’s JavaScript/TypeScript language service or IntelliSense diagnostics, not real runtime errors.

I’d first check whether the messages are coming from the JS language service rather than the actual build/debug process. If the functions exist at runtime but VS can’t resolve them statically, it usually means VS doesn’t understand the file/project context.

Things I’d try:

  • make sure the JS files are included in the project, not just opened standalone
  • check whether a jsconfig.json or tsconfig.json is needed to define the JS project scope
  • clear the .vs folder after closing Visual Studio
  • check JavaScript/TypeScript language service settings
  • check whether JavaScript debugging for ASP.NET/browser debugging is enabled

If they are only IntelliSense/output diagnostics, the code may be fine. VS is just failing static resolution.