Take note that you can't use server-side objects (including C# namespaces) directly inside external .ts files (with Razor syntax), such like external JS files. However, you can create hidden element in CSHTML file which has data- attribute to hold the integer value:
<div id="valueone" data-valueone="@MyConstants.ValueOne" style="display:none">...</div>
And convert it as constant integer value inside external .ts file with parseInt (suppose jQuery is used):
var valueOne = parseInt($('#valueone').data('valueone'));
Then put that value inside switch block as a case condition:
switch (value) {
case valueOne:
// do something
break;
// other cases
default:
// do something else
break;
}
References:
TypeScript Converting a String to a number
TypeScript within .cshtml Razor Files
Pass value from c# to cshtml to TypeScript
data-attribute in an element (e.g.data-valueOne) as replacement of direct usage with$('#elementId').data('valueOne')in TS side, but I want to know if you have separate .ts file to run the code..tsis in a separate file.