Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor (WA .NET6)- TS1109 Error, how to fix it?

I've been working on a Blazor WebAssembly .NET6 project for a couple of years. I updated VS2022 recently to the latest 17.10.0(I was in the previous 16.9 before), and after that I'm having TS1109 all over the razor files, my partner also is getting the same errors.

The error list

@inject IUserService UserService
@inject NavigationManager NavManager
@inject IDialogService DialogService
...

It is showing TS errors all the time pointing to the first lines of the opened .razor files, which are the @using or @inject lines that have been there since the start of the project. It allows me to compile and run, but it annoys mee seeing all those errors

I don't know if somoeone else ver here has experienced the same problem, I've tried a few things and nothing helped. Thanks in advance, and let me know if you need more info.

Tried deleting cache, obj and bin folders. Reinstalling VS2022, and setting the error list to just compilation instead of Intellisense, that last option only hides the error, but also hide other errors that are not TS related. My partner with the same version and project, and without VS extensions/addons is having the same issue, so it might not be addon related

*Edit: It has been patched and fixed with the 17.10.2 update https://developercommunity.visualstudio.com/t/TS1109-TS-Expression-expected-error-in/10635769

like image 959
luhia91 Avatar asked Oct 13 '25 01:10

luhia91


1 Answers

I have managed to turn off the latest VS2022 17.10.1 Intellisense's TS1109 errors for .razor files by selecting “Only report diagnostics for files opened in the editor” checkbox located in Tools -> Options -> Text Editor -> JavaScript/TypeScript -> Project -> General enter image description here Based on a workaround posted in VS Dev community: Workaround - Maria Solano [MSFT]

Hope this will work for you too - good luck!🤞

like image 188
Angel Dinev Avatar answered Oct 14 '25 17:10

Angel Dinev