TypeScript within .cshtml Razor Files
<p>I am starting a new project using ASP.NET-MVC framework. I'd like to use TypeScript in this project in place of JavaScript. TypeScript is easily supported by Visual Studio but doesn't seem to be (fully) compatible with the .cshtml razor files. I'm able to create my classes within the .ts file and call those classes within my .cshtml file, the issue is when I pass in parameters to the object in the .cshtml file TypeSafety is ignored and the function is run as if a type were never defined.</p>

<p><strong>.ts file</strong></p>

<pre><code>    export class SomeClass {

    name: number;

    constructor(public tName: number) {
        this.name = tName;
    }

    public sayName() {
        alert(this.name);
    }
}
</code></pre>

<p><strong>.cshtml file</strong></p>

<pre><code>var instance = new SomeClass("Timmy");
instance.sayName();
</code></pre>

<p>As you can see, I am passing a string to the constructor even though I clearly defined the parameter to only accept numbers, but the TypeSafely is ignored and the TypeScript/JavaScript executes as if there is no issue.</p>

<p>Both file types were invented by Microsoft so I'm slightly surprised they aren't a little more friendly with each other. This isn't the end of the world, at least I am still able to use Object Oriented Programming, I'm just curious if anyone else has experienced this and can maybe give me a brief explanation. </p>