TypeScript is a typed language that allows you to specify the type of variables, function parameters, returned values, and object properties.
Here...
For further actions, you may consider blocking this person and/or reporting abuse
A really well-written article with good examples. Good job!
Would like to add one more thing I like to use and you might find it interesting:
What are some really good real world examples for this? (3,4 examples).
Wouldn't the optional operator be enough?
The only thing I can think of is when you really need the parameter to be exactly
null
. But I never have this use case in the projects I work on, so I think something is fishy :))The difference between the two, is that in Maybe the value is required, and in the second one is optional. So, you can have Maybe values and those values would be either defined or not, but would still be required. I have found this to be useful in React.
Actually it's just personal preference to have null values instead of undefined.
The example I provided is actually not that great, because I tend to use this more with objects and their properties.
You should explicitly check for bar===null as in your case the empty string will also make !bar true
you are right, thanks :)
Great article! Please remember to use semicolons at the end of the lines.
The semicolon is not mandatory, I prefer to not use it. Thanks for reading BTW
No semicolon makes it look so much cleaner:)
Use prettier, you don't even have to type it yourself.
It's not mandatory if you wanna go against Google: google.github.io/styleguide/jsguid... . Please reconsider.
Theres a million different style guides, use whatever you want. No one is forced to use a specific one.
:) so glad I don't have to see or type those anymore
Congratulations! Really good article, very useful! I would like to add the possibility to create your own type guards on the type guard section, here is an example:
Great! A really good example, I will add it to the article.
i think
: obj is ImportantType
is ok, but can be more simpler:That defeats the purpose of using the type guard altogether. Typescript won’t infer the type from that function. :obj is ImportantType is the what tells typescript what the passed parameters type is. Hence type guard.
thanks for explain
But it wouldn't be a type guard though.
thanks for explain
Seems typescript is getting overcomplicated.
How so? These have been in it for a long time now. You are also not required to use them, since they're mostly syntactic sugar. It does make life easier a lot of times though!
Absolutely.
Good article, to the point and concise with good examples.
I wish I knew
Partial<T>
- that I just learnt here before. This is how I implemented it:Good article, nice to have everything combined in one place.
Thanks for reading too.
Really concise summary / recap.
Will share that with my team, thanks a lot !
Great! I'm glad this article could help.
It is a list of "easy to get" examples of the most interesting TS typing features, it's quite handy having them packed like this, thank you!
Great! I'm glad you find value in this article.
OMG, what I see! The first well wrote and detailed explanation of the typescript types system!!! Thanks a lot!!!
Awesome! I'm glad you find value on it.
Thank you for writing this article Ibrahima! I have been looking to update my beginner's TypeScript cheat sheet with utility types and this is the best explanation I've seen so far!!
Great! need this very much.
Thanks for sharing!
I want to translate it into Chinese to help more developers, Can I get your authorization?
I will give credit at the top of the article.
Yes, you can translate it. Just make sure to give me credit.
I saved in my Pocket and now I read and I can sau: great article. Thanks man!
Very concise and useful, This is the best blog that I read in last one month. Thanks a lot
Thanks for sharing!
How to did you added hoverable link in markdown?
In
TypeScript Guide (5 Part Series)
?