Top Tweets for #learnTS
Who remembers my typescript series last yr
#learnTS
Real ones know I'm on another series
Should I make a hashtag for this too?
Have you caught up with that 😅
#learnTS
Quizzz 😏
In TS, which is TRUE for default values?
It can be assigned:
A) in an interface for its properties
B) only in functions, not in types or interfaces.
C) by Generic type parameters to provide "defaults" in types and interfaces.
D) B and C are correct.
Back to my roots😅
#learnTS
12. OPTIONAL VS DEFAULT PARAMETERS
Adding "?" after a parameter makes it optional,
In the first image with greet("Sarah") the value of age is undefined.
Note that optional parameters must always come after required ones, why?
Scroll with me

#learnTS
11. TYPES VS INTERFACE
When do you decide which to use, or better yet do you combine them? Lets dig deep into the differences
Why? Their use-case may be similar but the syntax are definitely not 🧵
Bookmark so you don't forget😌
#learnTS
When using typescript with node.js, have you ever used hydrated-document before?
It is something I haven't really seen talked about
I'm thinking of writing a medium article on it. It is a cleaner way to extend your document types in your schema
PS: I use mongo dB
#learnTS
Quizz dayy🥳📢
What does infer help you do in TypeScript?
A. Infer the type of an object at runtime
B. Create conditional types that extract inner types
C. Automatically assign default values to types
D. Declare types in JSX files
Think twice before answering 🥂
#learnTS
Quiz dayyyy 🥳
type ID = number | string
type Point = [number, number]
What is Point?
#learnTS
9. UTILITY TYPES
This is a concise way of creating a new type from an already existing type or interface
In the pictures below, I use Pick as my example today. The first parameter is the origin type or interface that you want to copy and the second parameter 🧵

Thank you for the birthday wishes yesterday 🥹
#learnTS
8. INTERFACE IN TS
Interface does the same thing as type but in a different format
It is defined as an object.
All properties must be used and types must match the said properties.

#learnTS
7. TYPE(S) IN TYPESCRIPT
If this is confusing, use the hashtag to see where I'm coming from(previous posts).
Type is a very important concept in ts. It's very broad. Hovering over your code is good actually to confirm types

#learnTS
6. UNION ( | )
Think of it like the "or logical operation" but for types. It allows multiple valid types.
The type keyword lets you customise types.
The autocomplete feature of typescript is seen when types are declared.
Will talk more about types tomorrow.

#learnTS
Quiz dayyy 🥳
Which is risky and can break your app silently
#learnTS
5. NEVER TYPE
Before I knew anything about typescript, when I was using a React useState hook with a default value of empty array, typescript normally infers it to be a never type.
I was able to assign it values because a. It wasn't typescript
b. noImplicitAny : true

#learnTS
4. UNKNOWN TYPE
When dealing with a library with type not defined, you can use "unknown" type instead of "any"
A better alternative, in my opinion 😊

#learnTS
3. ANY DATATYPE
I avoid "any" datatype
What about when you use libraries that don't have type definitions ?
Tomorrow we will see about that

#learnTS
Quiz Timee 📢
let data;
What type will Typescript assign to data by default?
The answer highlights what will be discussed tomorrow
#learnTS
2.. TYPE ANNOTATIONS IN TYPESCRIPT
Implicit type annotation === inference
It is a very important concept in Typescript, where it guesses the variable type based on your input.
For both, the types assigned to a variable, function, parameter, etc, must be consistent.

#learnTS
1. TYPESCRIPT BASIC TYPES
First, let's look at type annotations in Typescript:
Implicit and explicit type annotations.
We are going to be using explicit type annotation to aid understanding, i.e., we will explicitly tell Typescript what each variable should be🧵

Most Popular Users

Elon Musk 
@elonmusk
240.8M followers

Barack Obama 
@barackobama
119.2M followers

Donald J. Trump 
@realdonaldtrump
111.7M followers

Cristiano Ronaldo 
@cristiano
111.1M followers

Narendra Modi 
@narendramodi
107M followers

Rihanna 
@rihanna
97.8M followers

NASA 
@nasa
92.2M followers

Justin Bieber 
@justinbieber
91M followers

KATY PERRY 
@katyperry
87.9M followers

Taylor Swift 
@taylorswift13
81.8M followers

Lady Gaga 
@ladygaga
73.3M followers

Virat Kohli 
@imvkohli
70.3M followers

Kim Kardashian 
@kimkardashian
69.9M followers

YouTube 
@youtube
68.7M followers

Bill Gates 
@billgates
64M followers

Neymar Jr 
@neymarjr
63.1M followers

The Ellen Show
@theellenshow
62.4M followers

CNN 
@cnn
61.9M followers

Selena Gomez 
@selenagomez
61M followers

X 
@x
60.8M followers




















