Right now we're using server-side code blocks in .aspx pages to generate JavaScript variables to be used by client side scripting;
Page.aspx
<html>
<head>
<script type="text/javascript">
<%=GenerateJavascriptVars()%>
// session variables, database values, etc.
// use the variables
</script>
</head>
<body>
<form></form>
</body>
</html>
This is fine, but I'm looking into TypeScript and there doesn't seem to be a good way to go about mimicking this setup, since TypeScript needs to know the type of these variables at compile time (so that the JavaScript files can be generated). I know about .d.ts files, but it doesn't seem like there is any benefit in defining things in two places, at that point why not just use native JavaScript?
I guess what I'm asking is, is TypeScript viable with our current setup? I'm beginning to think that the refactor may outweigh the benefits of strongly typed JavaScript. Is there something that I'm missing?
*.tsfiles, so you can't execute server-side script there unless you get the server side to generate the entire .ts file. I don't really like this approach anyway. You should create a web service which provides your Session Variables/DB Values/etc. and use a framework to ensure the data is loaded as a requirement (e.g. Angular)