This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div vocab="https://schema.org/" typeof="Actor"> | |
<span property="name">Millie Bobby Brown</span> starred in | |
<span property="movie" typeof="Movie" href="https://www.imdb.com/title/tt4574334"> | |
<span property="name">Stranger Things</span>. | |
</span> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media (prefers-reduced-motion: no-preference) { | |
button { | |
transition: all 300ms ease-in-out; | |
border: 2px solid rgba(255,255,255, 0.4); | |
transform: scale(1); | |
&:hover { | |
transform: scale(1.1); | |
border: 2px solid rgba(255,255,255, 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Article = { | |
title: string; | |
body: string; | |
image: string; | |
} | |
type ArticlePreview = Pick<Article, 'title' | 'body'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Article = { | |
title: string; | |
body: string; | |
image: string; | |
} | |
type ArticlePreview = Omit<Article, 'image'>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User = { | |
id: string; | |
email: string; | |
name?: string; | |
} | |
type AdminUser = Required<User>; | |
const admin: AdminUser = { | |
id: "1", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Person = { | |
id: string; | |
name: string; | |
} | |
const updateDetails = (person: Person, fieldsToUpdate: Partial<Person>) => ({ | |
...person, | |
...fieldsToUpdate | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Intersection types | |
type Office = { name: string } & Location; | |
// Mapped type | |
type Artist = { name: string, bio: string }; | |
type Subscriber = { | |
[Property in keyof Type]: (val: Type[Property]) => void; | |
} | |
type ArtistSub = Subscriber<Artist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Object literal | |
type User { | |
name: string; // allow only string | |
readonly email: string // email is also a string, but its immutable and cannot be changed | |
new: () => User; | |
new(): User; | |
[key: string]: string | number; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Ruler { | |
get size(): number; | |
set size(value: number | string): | |
} | |
const r:Ruler = ... | |
r.size = 100; | |
r.size = "100"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortBy = function<T extends SomeType> ((a, b): boolean, list: T[]): T[] { | |
return ... | |
}; |
NewerOlder