DEV Community

Introduction to TypeScript. Interfaces (opens in new tab)

Discussed on DEV

Basic syntax We know that we can use object literals to specify what property types we can use. However, what if you have multiple objects with the same structure? Interface is a programming structure that allows to create types for objects. interface Settings { color: string; delay: number; retry: boolean; } const mySettings: Settings = { color: "black", delay: 1000, retry: false } console.log(mySettings.color); Pay attention that when we define interface we use "semicolon". Optional propert...

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