When using MVC, I sometimes pass the server's model data to the client-side JavaScript by using Razor injected into the JavaScript, as follows:
<script type="text/javascript">
var myClientGuid = '@Model.MyServerGuid';
</script>
This sets a JavaScript variable named myClientGuid to the value of the server-side model property MyServerGuid. When it reaches the client, the code looks something like this inside the browser:
<script type="text/javascript">
var myClientGuid = 'EF0077AB-0482-4D91-90A7-75285F01CA6F';
</script>
This allows external JavaScript files to use this variable.
My question is, in TypeScript, since all code must be referenced via external files, what is the best way to pass server-side fields to TypeScript code? External code files cannot contain Razor code. Should I use the same technique as above, in the View, mixing JavaScript and Typescript within the project?