Reverse mapped types are just so super elegant for certain use cases...
Here we have an equivalent of `Promise.allSettled` that retains positional information for each item in the input
A new set of immutable Array methods (change array by copy) just reached Stage 4. So they are coming to the language!
[].toReversed, [].toSorted, [].toSpliced, [].with
const modifiers for type parameters are coming to TS 5.0, I had a feeling that this might happen soon
loving, loving it ❤️
declare function bar<const T>(obj: T): T;
bar([1, 'foo']) // readonly [1, 'foo'], and not (string | number)[]
Just opened a new PR to TypeScript - one that would allow people to opt into "partial inference".
The current problem is that once you supply any type argument - the rest can't be inferred (defaults are used). I'm trying to change that.
Feedback welcome
to overload functions or to not overload them in TS?
overloading is often easier but you might lose some control, especially when it comes to completions
you can often do better with "dynamic rest" technique
My 100th commit has just been merged to
@typescript
It’s a wild run, learned a shitload in the process and yet I still barely scratched the surface.
For more to come 🍻!
Instantiation expressions are coming to TypeScript. It will, sort of, become possible to have the deferred application of type arguments. Wonky experiment to experiment with the syntax below and link to the TS PR too:
@alistaiir
Dont put types condition first when u are using type:module at the top of ur package.json. It’s a mistake and TS wont resolve it it correctly from CJS-targeting files (authored in ESM) when using moduleResolution:node16
👩🎤 Emotion 11 is out! On 11/11 (at least in some parts of the world 😉). A year of tackling issues and helping the community - it wouldn't happen if not for the help of external contributors & the keen eye and the support of
@mitchellhamiltn
🚀
Reverse mapped types are extremely powerful in TypeScript - but very little known.
Example: inferring per tuple element types based on one of the element’s properties:
Isn't TypeScript just beautiful? 😜
Instantiations expressions are just awesome and probably way underutilized and little known! They require TS 4.7 though
Understanding the foundations of the type system comes in pretty handy. Sometimes it helps write faster types 🏎
You can play around with those examples here:
Please don't reimplement package resolution algorithms. Use libs - they exist for a reason and they are **battle tested**
Those few kbs that you can shave ain't worth the pain caused by the bugs you create by reimplementing this stuff
My 100th commit has just been merged to
@typescript
It’s a wild run, learned a shitload in the process and yet I still barely scratched the surface.
For more to come 🍻!
Oh man, i cannot lie,
It still feels like a lucky roll of die:
Moving from one amazing team
To the job from my dream.
State machines, readable logic, open source?!
That life of mine have not turned out the worst 😉
Time to share our current state. We're excited to announce the Stately team that will be working on the mission of making application logic more visual, robust, and accessible.
Stay updated and get early access here:
👩💻🧑💻👇
Stylis 4 has shipped - . Its a foundation of most css-in-js libs. A super tiny, fast and crazy as fuck css parser by
@thysultan
👏 ive helped with the newest release a little bit but this is all this man’s mind. Blessed for having a chance to work with him
nested `describe` blocks in tests are overrated... over time I often see tests added to random blocks because they are just appended~ to a file and nobody bothers finding the "proper" block. It's also hard to catch this during code review
just list them all flat...
Based on my recent findings - the best way to gain followers is to:
1. Post what has been merges to TS
2. Post about a jest config option
3. Engage with Dan Abramov in some super random thread
I think im going to focus on those strategies now
I've heard stories about M1 but executing a full TS test suite in under 2 minutes with fans barely being heard... this is ridiculous. My previous Mac took over 15 minutes to run through this and I could barely use it for other stuff in the meantime 😱 😱 😱
After more than 3 years - my old PR to React was kinda merged, making different types of memo components reusing old props more consistently during bailouts.
Don't let your dreams die, just wait patiently 🤣
Just opened a new TypeScript feature request... this time for "named type parameters", this is what
@tannerlinsley
often refers to as generic bags
declare function fn<{ a extends number, b }>(arg1: a, arg2: b): void
fn<{ a: 100, b: 'foo' }>(100, 'foo')
How to start debugging an infinite loop?
Just pause "at random" in devtools while looping and inspect the call stack. It might give you a lot of insight into what is happening.
You don't need a breakpoint to pause!
Just opened a new feature request for TypeScript - a new `preferinfer` type parameter modifier:
declare function get<T, preferinfer K extends keyof T>(obj: T, key: K): T[K]
get<User>({ name: 'Andarist', age: 32 }, 'name') // string
After many years & lots of feedback, we're finally announcing XState v5 beta 🚀
npm i xstate
@beta
• Powerful new statechart features ⚡️
• Actor logic for anything, not just state machines 🎭
• Reduced API surface area 🗜
• New docs 📚
• So many fixes & improvements ✨
What if instead of hitting instantiation limits on cyclic types, your validator could pass them to optimized, type-safe generics?
Everything you've been told about the limitations of TypeScript is a lie- you just have to be willing to think a bit of outside the box0️⃣1️⃣📦
Modern JS lib maintainer mantra: “please provide
@codesandbox
with the issue reproduced... please provide
@codesandbox
with the issue reproduced...”. Honestly cant imagine living without
@codesandbox
, the past without it feels grim nowadays
React landed its `experimental_useEvent` hook a few days ago. There are also tests there that show that the very same behavior can't be implemented in the user-land - those callbacks get updated ASAP, before any other effect types
Sometimes it's helpful to name "branches" of your conditional types in TypeScript and use pattern like this.
I've seen this in some cool libs like . I've always wondered if TS can smartly only compute the "chosen" branch...
1/2
Current status: time-travel debugging
@typescript
's node run in a browser.
@replayio
is a hero tool I don't deserve. My dev life consists of 2 major eras now - I call them pre-Replay and post-Replay
Already experimenting with the upcoming `const` modifiers for TS type parameters.
Thanks to a tip from
@ahejlsberg
I have a working spike for *recursive* validation of initial/states/ids in XState:
Did you know that this can be a dangerous operation?
const min = (arr: number[]) => Math.min(...arr)
If your `arr` is big enough - it will blow up your call stack 😉 It's also not totally a made-up problem, I've patched this issue yesterday in
@replayio
I opened a TypeScript PR with the PoC for extending reverse mapped types inference with the capability to infer *multiple* things per tuple element/object property through (what I call) concrete properties
Im pretty pumped about this potential feature 🤩
I can't express this enough but Preconstruct by
@mitchellhamiltn
( ) is fucking amazing for building libraries, especially for monorepos. It just amazes me how little spotlight it gets. Go and star it - or even better, use it and spread the love 🧡🎁
@erikras
memoizing the components is even a better optimization here - if u really need it. React might recognize that the return value is the same and might skip rerendering all of those Items altogether, without any prop checks nor anything else
Friendly reminder - if you are already on React 18 please make sure that you are using `createRoot` API and not the classic `ReactDOM.render`.
It might spare you some gotchas and save you from reundant rerenders
I would consider myself pretty good at TS, I even manage to fix some things in the compiler itself and yet...
I won't be able to ever internalize what {} and object types exactly mean 🤦♂️
Is it me or is it confusing for other people too?
Super excited about this one! Stayed up late yesterday after having small epiphany during the day (brains are weird, lol) and...
I managed to improve inference for context sensitive functions in mapped types