types are information about the structure in memory.... for example in C : a variable of the type integer allocates 4 bytes (ignoring the endians¹), so the compiler knows the bit chain 00000000 00000000 00000000 00000001 is 1 and not ' a ' (assuming the pointer points to the last byte²).
types can be used in branch predictions, for example you got 12 time a function that returns int a + int b. some modern compiler will inline the instructions for that so instead if 12 times a + b there is only 1 a + b. (as jump point for instructions in the memory)
types can be used to spot programmatic issues if you pass the wrong type into a function.
or for interface / type inferences.
basically types are a control structure that allows predictions about memory, process-flow, execution-model. The way they are applied/used varies based on the implementation of the compiler / interpreter.
I'm sure I forgot a lot of things.
typescript is a transpiler that will compile ts code into different JS (es5, es6, es2005) versions. the idea is to specify the interfaces and having a clear idea what's happening. basically eliminating the problem of "not knowing" what comes in and what goes out
hope that helped. or do you just mean Types in typescript ?
¹ endians the order bytes are read - left to right, right to left.
² ignoring the fact that the type char usually is only 1 byte long, hence it's more important where the pointer in memory points than the theoretical bit length of the integer, it could be seen as 4 characters not 1 as well I assumed a 32 bit architecture hence the integer is 4x8 bit