TS1109 when using an IHtmlHelper extension within a Razor View
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/TS1109-when-using-an-IHtmlHelper-extensi/10855884)._
---
[severity:It bothers me. A fix would be nice]
Create a new ASP.NET Core WebApp (MVC)
Define an IHtmlHelper extension like this:
```
public static IHtmlContent SomeExtension(this IHtmlHelper html)
{
return html. Raw("content");
}
```
Use it within a cshtml view like this:
```
<script>
var content = @Html.SomeExtension();
</script>
```
Getting this warning:

If I put the statement within quotes, the warning goes away. However, the purpose of the extension is to preserve the type of the content. So for example if the output value of the extension is "true", then the javascript line will become "var content = true;" which means that the type of "content" will be a boolean which is the desired outcome. If I put it in quotes then it will be a string.
The code still works, the only issue is the warning at this point which started coming up after an update to VS2022. Not sure which one, I believe it was around late 17.10 or early 17.11.
My current version is **17.12.5**
Thank you!
---
### Original Comments
#### Feedback Bot on 2/23/2025, 11:32 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
#### Feedback Bot on 2/27/2025, 02:47 PM:
This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.
Contributor guide
Assessment
This issue has not been assessed yet.