TypeScript code requires transpilation into JS.
But are expressions (that is anything that is valid as a right hand side of an assignment) also required to be transpiled?
Obviously a function (with type decorators) can appear as expressions and require transpilation:
const f = ():int => 42;
The return type decoration is TS specific and makes the expression ():int => 42
an invalid JS expression.
My question is more specific toward expressions that return a primitive type. And again, I can embed a TS function into the expression just for the kicks and that is obviously not JS compliant:
const x = (():int => 42)();
If the expression is “plain sequence of operators, literals and variables” without any deviation into function declarations, are there TS extensions that can appear?
PS. there are expressions that require functions, eg. somearray.map((x:int)=>x+1)
and the expression is TS not JS, but again this is because the function type decorators come into play. I’m looking for examples that do not involve functions, lambdas and the associated type decoration.