TypeScript 2.4 Flashcards

1
Q

dynamic import()

A

Promise-returning; can be await’ed

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

enum members can contain

A

string initializers

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

enums can be used in discriminated union types

A

type Shape = Circle | Square;

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

better inferring types, esp. with . . .

A

generics

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

TypeScript has always compared parameters in a . . .

A

bivariant way

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

a “weak type” is an interface with . . .

A

all optional params

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

what is an index signature

A

index signature to the weak type (i.e. [propName: string]: any) - can be anything as long as it’s not already defined as a property name

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

even assigning the entire ReadonlyArray back to a ___ is illegal

A

normal array

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

values that won’t change: ___ use const whereas ___ use readonly

A

variables / properties

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

values that won’t change: ___ use const whereas ___ use readonly

A

variables / properties

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

___ get special treatment and undergo ___ when assigning them to other variables, or passing them as arguments

A

Object literals / excess property checking

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

type assertion

A

(i.e. opts as Options)

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

function type

A

interface SearchFunc {
(source: string, subString: string): boolean;
}

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

This index signature states that when a StringArray is indexed with a number, it will return a string.

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

tagged union type

A

a union type whose member types all define a discriminant property of a literal type (TS2.0)

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

There are two types of supported index signatures

A

string and number

17
Q

tagged union type example

A

interface PayPal {
kind: “paypal”;
email: string;
}

interface CreditCard {
    kind: "credit";
    cardNumber: string;
    securityCode: string;
}
18
Q

class-interface merging

A

declaring both a class and an interface of the same name