Daniel Fry
@danfrydev
Followers
352
Following
3K
Media
2
Statuses
62
Software Engineer @chase_uk
London
Joined February 2022
Goal: Calculate a value once per render. Mistake: Declaring a parameterless function. Why? Because then the function may be needlessly called multiple times on every render. Solution: If a function takes no args, declare a variable instead.
18
19
375
Here's my favourite method for getting Go/Zig/Rust-like errors in TS. It's by returning custom errors from functions. - Shows right in the return type - Easy checking with instanceof - No deps required
93
79
2K
loving this pattern to avoid redundancy in complex class declarations...extract the props from the class prototype and use it as the constructor argument โ
typesafe โ
no redundant interfaces โ
constructor becomes a one-liner
39
85
1K
TypeScript problem: You need to support any string value, but youโd like autocomplete support for common values. Solution: Create a union with "string & {}" on the end. Now you get autocomplete support for all values listed in the union, but can still enter any value.
20
87
858
TypeScript v5.5 is going to be soooo amazing ๐ฅ The type-checker will now be able to *infer* type predicates for us ๐ And there's more. Type predicates will โจcomposeโจ! Huge, huge thanks to @danvdk for landing this PR, I'm so excited about this!
8
40
228
๐ด Tired: enabled not doing any type narrowing ๐ Wired: the brand new skipToken ๐ฅ Now available in v5.25.0
21
40
529
I wrote a game of TicTacToe using only TypeScript's type system
10
10
207
The Mac turns 40 today ๐ To celebrate, we're giving away Raycast Pro with GPT-4 for one year to 40 people. Simply retweet this tweet and follow @raycastapp to enter. Winners will be announced by the end of the week.
63
965
737
๐ So I finally found the time to write about why we made the breaking parameter changes in v5, and what this new API enables us to do. Prepare to have your mind blown if you don't yet know what the Query Options API can do for you ๐คฏ https://t.co/MAXFZVCzH1
tkdodo.eu
v5 brought a new, powerful API, especially if you're using React Query with TypeScript...
13
42
379
TypeScript 5.4 will bring a new utility type: NoInfer. This will be EXTREMELY useful for generic functions where you have multiple candidates for inferring a type. In the example below, we use NoInfer to make sure that 'initial' must be one of the states passed.
33
138
1K
๐ขAnnouncing TanStack Query v5 ๐๐ฅณ ๐ค unified object API ๐ simplified, optimistic updates โป๏ธ sharable mutation state ๐ suspense and streaming w/ RSC โพ๏ธimproved infinite queries โก๏ธ ~20 % smaller ๐ ๏ธnew agnostic devtools ๐พ fine-grained persistence
60
316
2K
โ Avoid listening for ref changes with useEffect() in React. โ
Instead use a ref callback function.
17
148
981
๐ฅ JavaScript Sets are about to become a lot more useful with these 7 new methods: .difference() .intersection() .symmetricDifference() .union() .isSubsetOf() .isSupersetOf() .isDisjointFrom()
82
821
5K
โ Avoid difficult-to-read conditionals to render elements in react. โ
Instead use utility components for conditional rendering.
63
234
2K