TypeScript Flashcards
What is Type Inference?
When a variable is declared with an initial value, the variable can never be reassigned a value of a different data type.
What is TypeScript?
A programming language that adds types to JavaScript. It allows us to write JavaScript with a set of tools called a type system that can spot potential bugs in, clarify the structure of, and help refactor our code.
What is Type Shapes?
An object’s shape describes, among other things, what properties and methods it does or doesn’t contain. TypeScript will let you know if your code tries to access properties and methods that don’t exist.
What is a variable type of any in TypeScript? When is an instance where this occurs?
Variable type any is when TypeScript will not try to infer what type a variable is - generally when a variable is declared without being assigned an initial value. TypeScript won’t give an error if they’re reassigned to a different type later on.
What are Variable Type Annotations (Type Declarations)? How do you do it?
Declaring a type for a variable. Declaring a variable without an initial value while still ensuring that it will only ever be assigned values of a certain type. Append a variable with a colon ( : ) and the type (e.g., number, string, any)
What is the tsconfig.json File for?
Settings for TypeScript, where certain default rules are not enforced. With this file include in the root, you can run the “tsc” command.