TypeScript Flashcards

1
Q

What is Type Inference?

A

When a variable is declared with an initial value, the variable can never be reassigned a value of a different data type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is TypeScript?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Type Shapes?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a variable type of any in TypeScript? When is an instance where this occurs?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Variable Type Annotations (Type Declarations)? How do you do it?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the tsconfig.json File for?

A

Settings for TypeScript, where certain default rules are not enforced. With this file include in the root, you can run the “tsc” command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly