The gains that come from using typescript are productivity gains: in big projects static typing, generics, decorators, and interfaces are supposed to be a boost to productivity, not a boost to performance.
Also even if you can't statically determine the types of some variables typescript seems to be able to determine it for most. If most of the objects are statically known would it give you a large part of the speed up of a totally static system? In Java and C# there's still some intentional holes in the type systems like the dynamic keyword or casting to object
Nope, it's never been the case, even with all the flags on. It's not about implicit casts, it's about soundness in the actual type rules. Here's an example:
function append(array: Array<Object>) {
array.push("not a number");
}
var nums: Array<number> = [];
append(nums);
console.log(nums[0].toFixed());
If you run this, it throws an exception because String does not have a "toFixed()" method.> If most of the objects are statically known would it give you a large part of the speed up of a totally static system?
Maybe, but it's hard to say. Once you have a single hole, if you can't check it at runtime right at the hole, then values of the wrong type can spread anywhere in the program.
> In Java and C# there's still some intentional holes in the type systems like the dynamic keyword or casting to object
Right. In the above example, Java and C# would throw an exception when you added the string to the array. This check has some runtime cost, but works.
I believe TypeScript is also unsound around function types, which is harder to address because there's no easy place to know where to add the check.
Sure, sometimes you might be able to generate more efficient code by tailoring the emitted Javascript to the VM behaviour or using something like typed arrays for low level operations, but if the target language doesn't have support for certain things like type hinting, there is not much that could be gained.