I have this typescript code:
function fooAlert(text: string): void {
alert(text);
}
namespace BarNamespace {
export function barAlert(text: string): void {
alert(text);
}
export class BarEmpty {
}
}
The typescript code is transpiled to javascript using gulp tasks:
function fooAlert(text) {
alert(text);
}
var BarNamespace;
(function(BarNamespace) {
function barAlert(text) {
alert(text);
}
BarNamespace.barAlert = barAlert;
var BarEmpty = function() {
function BarEmpty() {}
return BarEmpty;
}();
BarNamespace.BarEmpty = BarEmpty;
})(BarNamespace || (BarNamespace = {}));
The problem is, that IntelliSense in Visual Studio 2019 does not work in Razor markup as I would expect. For example I have this asp.net MVC Core 3.1 view (.cshtml):
<!DOCTYPE html>
<html lang="en">
<head>
<script src="~/Site.js" asp-append-version="true"></script>
</head>
<body>
<script>
fooAlert("foo"); // IntelliSense match after typing f
BarNamespace.barAlert("bar"); // IntelliSense match after typing B for BarNamespace but not for .barAlert
</script>
</body>
</html>
When I type f then fooAlert(text: any): void is listed twice (with any instead of string). I guess once for the javascript file in my solution and once for the typescript file.
When I type B then BarNamespace is listed. After I type BarNamespace and . nothing is listed.
I also have a .js.map file but I can't see any changes when I add it next to the js file.
Am I doing something wrong or is there a way to improve the IntelliSense suggestions in Visual Studio 2019? The script is working in the browser, but it would be much easier and safer to have useful IntelliSense suggestions, at least for the available methods.