TypeScript 2.4 Flashcards Preview

TypeScript > TypeScript 2.4 > Flashcards

Flashcards in TypeScript 2.4 Deck (18)
Loading flashcards...
1

dynamic import()

Promise-returning; can be await'ed

2

enum members can contain

string initializers

3

enums can be used in discriminated union types

type Shape = Circle | Square;

4

better inferring types, esp. with . . .

generics

5

TypeScript has always compared parameters in a . . .

bivariant way

6

a "weak type" is an interface with . . .

all optional params

7

what is an index signature

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

8

even assigning the entire ReadonlyArray back to a ___ is illegal

normal array

9

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

variables / properties

10

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

variables / properties

11

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

Object literals / excess property checking

12

type assertion

(i.e. opts as Options)

13

function type

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

14

[index: number]: string

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

15

tagged union type

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

16

There are two types of supported index signatures

string and number

17

tagged union type example

interface PayPal {
kind: "paypal";
email: string;
}

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

18

class-interface merging

declaring both a class and an interface of the same name