DEV Community

Introduction to TypeScript. Special TypeScript data types (opens in new tab)

Discussed on DEV

Arrays and tuples array - collection of items (similar to JavaScript). In TypeScript we can specify what value types we expect for items to be: let arr: number[] = []; arr[0] = 1; arr[0] += "string"; // Type 'string' is not assignable to type 'number' we can declare nested arrays like this: let arr: string[][] = [["string1"], ["string2"], []]. tuples - fixed length array that has predefined types for each position: let tup: [number, string] = [1, "text"]; tup[0] = 2; tup[1] = 3; //Type 'numbe...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help