No BS TS #11 - Enums and Literal Types in Typescript

  Рет қаралды 18,087

Jack Herrington

Jack Herrington

Күн бұрын

Пікірлер: 32
@achillesnakmuay
@achillesnakmuay 3 жыл бұрын
Dude these videos... I've been developing professionally for 7 years and this is one of the easiest to digest channels I've ever come across.
@adamlerman4173
@adamlerman4173 3 жыл бұрын
I never comment on youtube (or anywhere really) but I felt like I just had to let you know, these videos are the single most valuable thing I have found in order to learn ts. THANK YOU SO MUCH
@johnnyutah23
@johnnyutah23 4 ай бұрын
Today I learned I've been pronouncing enums wrong all this time! Great videos!
@zykoz6826
@zykoz6826 2 жыл бұрын
Enumerations are one of my favorite ways to keep code clean!
@zykoz6826
@zykoz6826 Жыл бұрын
Literally the best `${...content}` around. No BS
@pratikmakune2881
@pratikmakune2881 3 жыл бұрын
Absolutely loving your content Jack. Thanks so much :) Can you please also suggest any course for Object-Oriented Programming/Designing using Typescript in greater depth, I have upcoming assignments on those lines.
@techhguy
@techhguy 3 жыл бұрын
One Word Description = Awesome!
@JulioDx3480
@JulioDx3480 3 жыл бұрын
Thanks for this series, I am learning a lot.
@arghyamitra3281
@arghyamitra3281 3 жыл бұрын
U sir becoming my favourite
@francis_n
@francis_n 3 жыл бұрын
Great video as always Jack. Have a question. When you constrain the values to rollDice function, what happens if the callee pass it argument which is a variable and it is not in the constrained value range of 1 | 2 | 3 | 4?
@jherr
@jherr 3 жыл бұрын
I think you'd have to assert that it's one of those values.
@raminkhodaie4063
@raminkhodaie4063 Жыл бұрын
what if we want to implement the last concept and example with concept of arraow function?what would be the code snippet for this? the example at 6:00
@jimshtepa5423
@jimshtepa5423 2 жыл бұрын
Another very informative material. Thank you, Jack. A quick question: the englishLoadingState object you defined at 2:50, was it intended to explain enums? or use of enums? Could you please clarify what was it you wanted to demonstrate?
@Blumi
@Blumi 3 жыл бұрын
I love this series but imo it should be Math.random() * 6, not 5.
@jherr
@jherr 3 жыл бұрын
Yeah, true.
@BHFJohnny
@BHFJohnny Жыл бұрын
Just out of curiosity, I found that fully symmetrical 5-sided dice is not possible (At least in 3d world), but there's a symmetrical 10-sided dice where each value is present twice. Who'd knew, huh? 🤔
@yokevinmendez
@yokevinmendez 2 жыл бұрын
Good video, I just want to say; I prefer always use literal types instead of enums, because use literal types is more readable for me.
@jherr
@jherr 2 жыл бұрын
I kinda go back and forth on it myself.
@justinmooney1398
@justinmooney1398 3 жыл бұрын
These videos are terrific.Here's something I've never quite understood though: What is the advantage of using an enum (particularly if you assign strings as the property values like you've sensibly done here) over just using a regular js object and referencing properties from that object. Do you have any insight to this, Jack? enum LoadingState { beforeLoad = "beforeLoad" loading = "loading", loaded = "loaded", } const loadingState = { beforeLoad: "beforeLoad" loading: "loading", loaded: "loaded", }
@jherr
@jherr 3 жыл бұрын
Problem with the const version is that your signature would look like `isLoading(state: keyOf loadingState): boolean` as opposed to `isLoading(state: LoadingState): boolean`.
@justinmooney1398
@justinmooney1398 3 жыл бұрын
Ah, makes sense. Thanks for quick reply.
@alaxalan3667
@alaxalan3667 3 жыл бұрын
Awesome :)
@kettenbach
@kettenbach 3 жыл бұрын
loaded ☝️😀
@dannyroberts4067
@dannyroberts4067 Жыл бұрын
I like this guy, he's obviously an amazing dev'. I would suggest however that he slows down and spends a bit more time explaining, I feel like he doesn't seem to enjoy the teaching and just rattles through what he's doing in the moment.
@kncle
@kncle 2 жыл бұрын
I have a question. Why would I use an enum when I can create a type with unions instead? It has the same functionality but doesn't require the dot syntax. Also easier when looking at values for example, coming from a JSON file I found. Love the videos. I love typescript and I had no idea howm many features it had until I saw your series
@flibben
@flibben Жыл бұрын
Wow, string literals with function overloads - so cool! Didn't even know what function overload was before this video. Thank you for all the quality content, keep it up!
@hadeedtmgggg5837
@hadeedtmgggg5837 10 ай бұрын
My string literal code give all two option although I write the same code
@TheRFracer
@TheRFracer Жыл бұрын
Absolutely top content... the best TS course you can find on youtube
@falias4
@falias4 2 жыл бұрын
Great content so far! I also started with enums but I prefer the union type whenever possible.. unless there's a hard reason for an enum.
@大盗江南
@大盗江南 2 жыл бұрын
Sincerely thank you for all these quality videos buddy!
@meyourstubes
@meyourstubes 7 ай бұрын
never learned so fast in that short time. Thank you so much. I really like your speed and detail level; in conjunction with good hints and background, where to use it, and what to avoid. (: fun-fact, it's a loaded dice; please use "rand() * 6 + 1" if you ever want to have a 6 as result)
@chrisvetrano8282
@chrisvetrano8282 2 жыл бұрын
Amazing videos... I needed a TS refresher course after being out of TS for 8 months and this has been perfect. Thank you.
No BS TS #12 - Typescript Classes; Member Visibility and Implements
9:09
TypeScript Wizardry: Recursive Template Literals
14:47
Tech Talks with Simon
Рет қаралды 38 М.
Officer Rabbit is so bad. He made Luffy deaf. #funny #supersiblings #comedy
00:18
Funny superhero siblings
Рет қаралды 7 МЛН
Самое неинтересное видео
00:32
Miracle
Рет қаралды 2,9 МЛН
TypeScript - Enums: Обзор и когда не надо использовать
11:24
PurpleSchool | Anton Larichev
Рет қаралды 15 М.
No BS TS #14 - Mapped Types in Typescript
9:33
Jack Herrington
Рет қаралды 22 М.
How to use TypeScript Enums and why not to, maybe
12:43
Andrew Burgess
Рет қаралды 19 М.
No BS TS #21 - Typescript/React - Hooks
11:41
Jack Herrington
Рет қаралды 12 М.
Bad behaviour of objects in typescript
9:48
Hitesh Choudhary
Рет қаралды 22 М.
TypeScript Enums are TERRIBLE.  Here's Why.
14:05
Michigan TypeScript
Рет қаралды 68 М.
RUST Enums ARE Better
5:49
ThePrimeagen
Рет қаралды 142 М.
.NET 7 Update: Raw String Literals in 10 Minutes or Less
10:17
IAmTimCorey
Рет қаралды 10 М.
Officer Rabbit is so bad. He made Luffy deaf. #funny #supersiblings #comedy
00:18
Funny superhero siblings
Рет қаралды 7 МЛН