February 2019
Beginner
694 pages
18h 4m
English
TypeScript also uses a technique called inferred typing to determine the nature of a variable. This means that even if we do not specify the type, the compiler will check where the variable has first been used, and then use this type for the remainder of the code block. As an example of this, consider the following TypeScript code:
var inferredString = "this is a string""; var inferredNumber = 1; inferredString = inferredNumber;
We start by declaring a variable named inferredString and assign a string value to it. TypeScript identifies that this variable has been assigned a value of type string and will infer that the inferredString variable is of type string. Any further usage of this variable, therefore, will need to treat ...
Read now
Unlock full access