TypeScript Flashcards

(48 cards)

1
Q

What is TypeScript?

A

TypeScript is a superset of JavaScript that adds static typing.

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

Static Typing

A

TypeScript allows you to define variable types, making code more predictable and easier to debug.

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

Transpilation

A

TypeScript code is compiled into JavaScript for execution in browsers or Node.js.

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

TypeScript File Extension

A

TypeScript files use the .ts extension.

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

Benefits of TypeScript

A

Improves code quality, better error detection, supports modern JS features.

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

Interfaces

A

Used to define contracts for objects, specifying their structure.

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

Classes in TypeScript

A

Allow for creating objects with defined properties and methods, supporting OOP principles.

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

Enums

A

Define a set of named constants, making code more readable.

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

Generics

A

Enable writing reusable and type-safe code components.

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

Union Types

A

Allow variables to hold more than one type, e.g., string | number.

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

Type Aliases

A

Provide a way to name and reuse custom types.

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

Literal Types

A

Restrict a variable to specific values, e.g., let direction: ‘up’ | ‘down’.

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

Type Inference

A

TypeScript can infer variable types based on assigned values.

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

Any Type

A

A type that disables type checking, useful in dynamic code.

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

Never Type

A

Indicates values that never occur, e.g., in unreachable code.

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

Void Type

A

Used for functions that don’t return a value.

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

Tuple

A

An array with fixed types and length.

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

Type Assertion

A

Tell the compiler to treat a value as a specific type using as or <>.

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

Optional Parameters

A

Functions can define optional parameters with the ? syntax.

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

Readonly Modifier

A

Prevents reassignment of properties or variables.

21
Q

Access Modifiers

A

Keywords like public, private, and protected control property access.

22
Q

Default Parameters

A

Functions can have parameters with default values.

23
Q

Decorators

A

Special annotations used to modify classes or methods at runtime.

24
Q

Namespaces

A

Used to organize and group related code.

25
Modules
Allow splitting code into reusable files and importing/exporting between them.
26
TypeScript Compiler
The tsc command compiles TypeScript to JavaScript.
27
Configuration File
tsconfig.json configures TypeScript compiler options.
28
Strict Mode
Enabled in tsconfig.json to enforce strict typing rules.
29
Declaration Files
Files with a .d.ts extension provide type definitions for JavaScript libraries.
30
Mapped Types
Transform properties in a type, e.g., making them optional.
31
Intersection Types
Combine multiple types into one using &.
32
Keyof Operator
Get all keys of a type as a union.
33
Indexed Access Types
Access the type of a property in an object type.
34
Utility Types
Predefined types like Partial, Readonly, Record, etc., for common transformations.
35
Type Guards
Runtime checks to ensure a variable matches a specific type.
36
Abstract Classes
Classes that cannot be instantiated but can be extended.
37
Promises in TypeScript
Handle asynchronous operations with typed Promises.
38
Error Handling
Use try-catch blocks with type-safe error objects.
39
Compatibility with JS
TypeScript is fully compatible with existing JavaScript code.
40
DOM Manipulation
Type-safe interaction with HTML elements using TypeScript.
41
Function Overloading
Define multiple function signatures for one implementation.
42
Constructor
Special method in classes for initializing objects.
43
Static Members
Class-level properties or methods shared across all instances.
44
TypeScript Playground
Online editor to experiment with TypeScript code.
45
Tooling Support
Integrated into many IDEs like VS Code for autocompletion and type checking.
46
Code Refactoring
Simplified and safer refactoring with static type checking.
47
Community Support
Growing community and resources for TypeScript developers.
48
Migration
Easily migrate JavaScript projects incrementally to TypeScript.