Reputation: 2187
Is it possible to use typescript within <script/>
tags?
<script type="text/typescript">
...
</script>
Context: My platform is ASP.NET Core 2.1 using razor MVC (.cshtml).
Upvotes: 0
Views: 189
Reputation: 184296
Yes it is possible. You can run a filter that replaces all script tags with that type with the compiled source (and the text/javascript
type).
I have implemented that before but it was really slow because i did not find any typescript compiler assembly that could be called directly. Calling the tsc
executable, which also requires a file (that i temporarily created) takes very long. If you have no static components you could cache it of course.
Also, if you use VS, it does not recognize those tags properly so you do not get highlighting or completion which is a pain.
Upvotes: 1