TS5055 error when extracting JavaScript from cshtml file

While this does appear to work, Visual Studio is raising TS5055 errors when editing the Javascript files. What I want to do is extract the JavaScript declared in the view into a separate file rather than just embedding it in the end of the .cshtml file within a @section scripts { }

So for instance instead of:

@section scripts{
    <script type="text/javascript">
        var userDetailUrl = '@Url.Action("Detail", "UserManagement", new {userId="@userId"})';

        // ...

        function loadData() {
            fetch('GetUsers')
                .then(response => {
                if (response.ok) {
                     return response.json();
                }
                throw new Error(response.statusText);
            }).then(data => {
                 asyncTable.update({
                      rows: data.map(user => ({
                          pid: user.pid,
                          name: user.lastName + ', ' + user.firstName,
                          action: '<a href="' + userDetailUrl.replace('@userId', user.userId) + '">' + user.pid + '</a>'
                   }))
            }, {
                loading: false
            });
        });

    </script>
}

I want to move the functions and such into a separate .js file nested under the view’s cshtml file. So for instance:

 - List.cshtml
     - List.cshtml.js

using Visual Studio 2022 file nesting rules.

In this way my script section is updated to:

@section scripts{
    <script type="text/javascript">
        var userDetailUrl = '@Url.Action("Detail", "UserManagement", new {userId="@userId"})';
    </script>
    <script src="@Url.Content("~/Views/UserManagement/List.cshtml.js")" asp-append-version="true"></script>
}

with the script file (List.cshtml.js) containing the loadData() and other relevant functions.

Now this all works, but in Visual Studio, if I have the .cshtml.js file open in the editor, without making any changes at all, within a few seconds I get a TS5055 error:

Cannot write file ‘…./UserManagement/List.cshtml.js’ because it
would overwrite input file. Adding a tsconfig.json file will help
organize projects….

This appears under a Project of “Miscellaneous” rather than the specific web project.

Now my thoughts here is that with ASP.Net MVC creating JS automatically for views, perhaps it is somehow expecting to reserve a .cshtml.js file for it’s own use, though I cannot see any such script file normally being generated for views.

Where it gets very odd is if I rename the file to something like “List.scripts.js”. I change the <script src="@Url.Content("~/Views/UserManagement/List.scripts.js")" asp-append-version="true"></script>

Now the TS5055 error does not come up when I have the file open in the VS editor, however, when running the application it returns a 404 for the script file! I have double-checked in IIS going to the Views/UserManagement folder and explored to ensure this wasn’t something like going to a different location where a “copy local” might be an issue, the file is present at that location but somehow it isn’t located. When the file and reference are named “List.cshtml.js”, the file is found and works. I had tried without the “asp-append-version” in case that was being problematic but that doesn’t make any difference.

As far as I can see, the code is working despite the TS5055 error when the script file is open in the editor, but I don’t know if this will manifest into actual problems later and I would prefer not having to start ignoring errors in the build output.