Daniel Fry retweeted
hey. here's a little demo of the most meaningful improvement to my productivity since speech-to-text.
Daniel Fry retweeted
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.
Daniel Fry retweeted
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
Daniel Fry retweeted
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
Daniel Fry retweeted
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.
Daniel Fry retweeted
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!
Daniel Fry retweeted
😴 Tired: enabled not doing any type narrowing
🚀 Wired: the brand new skipToken 🔥
Now available in v5.25.0
Daniel Fry retweeted
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.
Daniel Fry retweeted
📚 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 🤯
tkdodo.eu/blog/the-query-opt…
Daniel Fry retweeted
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.
Daniel Fry retweeted
📢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
Daniel Fry retweeted
Implemented safe triangles to improve submenu selection in @shoelace_style today.
Daniel Fry retweeted
❌ Avoid listening for ref changes with useEffect() in React.
✅ Instead use a ref callback function.
Daniel Fry retweeted
🔥 JavaScript Sets are about to become a lot more useful with these 7 new methods:
.difference()
.intersection()
.symmetricDifference()
.union()
.isSubsetOf()
.isSupersetOf()
.isDisjointFrom()
Daniel Fry retweeted
❌ Avoid difficult-to-read conditionals to render elements in react.
✅ Instead use utility components for conditional rendering.
















![import { skipToken, useQuery } from '@tanstack/react-query';
const [filter, setFilter] = React.useState<Filter>()
const { data } = useQuery({
queryKey: ['todos', filter],
queryFn: () => fetchTodos(filter) : skipToken,
enabled: !!filter,
});](https://pbs.twimg.com/media/GH6pNToXkAAn0KF.png?name=small&format=webp)
![import { skipToken, useQuery } from '@tanstack/react-query';
const [filter, setFilter] = React.useState<Filter>()
const { data } = useQuery({
queryKey: ['todos', filter],
queryFn: filter ? () => fetchTodos(filter) : skipToken,
});](https://pbs.twimg.com/media/GH6pU2wWsAA458C.png?name=small&format=webp)











