My Favorite TypeScript Tips and Tricks

  Рет қаралды 4,648

Lachlan Miller

Lachlan Miller

Күн бұрын

🎉 Writing a book about tooling, testing and development philosophy: lachlan-miller.ck.page/92dfa0...
📗 Book (Vue, Updated Aug 2023): lachlanmiller.gumroad.com/l/v...
📖 Type Challenges to learn and push yourself github.com/type-challenges/ty...
🐦 My Twitter: / lachlan19900
Some neat TypeScript tips and tricks I've learned over the years. Now you know them, too!

Пікірлер: 17
@studiowebselect
@studiowebselect 4 ай бұрын
type __Awaited = T extends Promise ? U : T will work and no recursivity
@LachlanMiller
@LachlanMiller 4 ай бұрын
Good catch - I've always used the recursive snippet, but it's overkill for what I was demonstrating here.
@studiowebselect
@studiowebselect 4 ай бұрын
@LachlanMiller by the way, I learn so mush from you. Love your videos! Continue your great work
@LachlanMiller
@LachlanMiller 4 ай бұрын
Thanks@@studiowebselect ! Trying to get back into a habit of posting content. Knowing people find it useful really motivates me!
@user-dw2ce5tb1k
@user-dw2ce5tb1k 4 ай бұрын
What about nested promises tho. Wont work for those
@LachlanMiller
@LachlanMiller 4 ай бұрын
@@user-dw2ce5tb1k Yeah, depends what you want. The recursive solution handles the nested cases. Here's the actual one from TypeScript: gist.github.com/lmiller1990/067b9d296bf5a3b05151437009ad7235
@siyedyoussef3202
@siyedyoussef3202 4 ай бұрын
love this kind of video it open your eyes about some typescript magic keep up the great work
@LachlanMiller
@LachlanMiller 4 ай бұрын
Thank you!
@yassinebenazouz4529
@yassinebenazouz4529 4 ай бұрын
very helpful thank u ^ ^
@user-ug8qc6tr6b
@user-ug8qc6tr6b 3 ай бұрын
Great content! keep going
@LachlanMiller
@LachlanMiller 3 ай бұрын
Thank you, will do s🫡
@EdwinMartin
@EdwinMartin 4 ай бұрын
“It isn’t a true constant variable, like it is in other languages” That not true. In C++, Java (final), C# (sealed) and probably others, it works just like JavaScript.
@LachlanMiller
@LachlanMiller 4 ай бұрын
My bad, I don't know enough other languages. I guess what I meant was I expect keyword claled "const" to be immutable and, well, constant! Thanks for pointing this out.
@snatvb
@snatvb 4 ай бұрын
2:17 - it's tuples
@LachlanMiller
@LachlanMiller 4 ай бұрын
It's called a tuple? I thought a tuple was something different, like `type T = [number, string]`. Is this really the same type?
@snatvb
@snatvb 4 ай бұрын
​@@LachlanMiller ahhh, maybe I understand you wrong when you use "as const" for array you will get tuple (really strict, with literals in your case), as I get you mean foo[number] - this way to get something from foo it's part of cycles in typescript (keyof works same inside ts) you can use foo[string] as well, or template strings inside recursive types to filter something
Vue's New Rendering Strategy (Vapor), Innovation vs Maintenance
7:22
TypeScript Slows You Down - Here’s Why
5:44
Theo - t3․gg
Рет қаралды 38 М.
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 32 МЛН
Pray For Palestine 😢🇵🇸|
00:23
Ak Ultra
Рет қаралды 34 МЛН
狼来了的故事你们听过吗?#天使 #小丑 #超人不会飞
00:42
超人不会飞
Рет қаралды 62 МЛН
Any vs Unknown In TypeScript
0:58
Web Dev Simplified
Рет қаралды 92 М.
The TRUTH About TypeScript Enums
12:04
James Q Quick
Рет қаралды 5 М.
Is Zed the VS Code Killer?
2:31
TechFlex
Рет қаралды 4,8 М.
TypeScript 5.3 Beta | Prime Reacts
16:35
ThePrimeTime
Рет қаралды 49 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 107 М.
I Wish I knew This About Typescript & React Sooner
14:06
CoderOne
Рет қаралды 37 М.
Visual Guide to the Modern Frontend Toolchain (Vite)
9:18
Lachlan Miller
Рет қаралды 74 М.
3 Ways to Avoid Prop Drilling in Vue/React
9:34
Lachlan Miller
Рет қаралды 4 М.
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 340 М.
cool watercooled mobile phone radiator #tech #cooler #ytfeed
0:14
Stark Edition
Рет қаралды 7 МЛН