Profile avatar
andarist.bsky.social
programmer but also a little bit of code-poet wannabe, maintaining XState, Emotion, Changesets, redux-saga & more, OSS enthusiast
166 posts 5,479 followers 224 following
Getting Started
Active Commenter
comment in response to post
comment in response to post
comment in response to post
Simple? I dont think so. Those are anonymous object types~ with unique identities (even if they look the same)
comment in response to post
but also... if ur types would contain Animal and Dog that would reduce to just Animal (cause Dog is a subtype of Animal and redundant subtypes are eliminated in this situation). So it might not be exactly what u want either, YMMV
comment in response to post
just for the fun of it, this one works, since in unionizing those conditional expression branches goes through subtype reduction: www.typescriptlang.org/play/#code/M...
comment in response to post
A distributive Omit wouldn't solve ur case either: www.typescriptlang.org/play/#code/M...
comment in response to post
Omit doesn't distribute so it selects shared keys from all of your input types and then omits the requested keys - but that first step creates a new flattened (sort of) type (that's why it seems to work in the simple case)
comment in response to post
you totally dont want to use either of those here: www.typescriptlang.org/play/#code/M...
comment in response to post
comment in response to post
it's certainly fixable today because the compiler could emit an import type statement and aut-generate a valid local identifier for what it wants but perhaps the TS team would like to make it work with `import().Type`
comment in response to post
this sums up the core of the issue: www.typescriptlang.org/play/#code/J...
comment in response to post
ah, I see - it's worth raising an official TS issue about it. The problem is there is no clear way to synthesize a reference to this type using import("foo").Type syntax and that's how type references are emitted
comment in response to post
It’s called the cloak of invisibility
comment in response to post
Ah cool, I wasnt sure if this landed already. If u manage to make that repro case - ping me :p
comment in response to post
Are arbitrary string exports already supported by TS? They were not not that long time ago iirc
comment in response to post
comment in response to post
I don't have any tricks up my sleeve here, sorry ;p You might try to ping the team on GitHub but upvoting itself is probably not that effective. You could mention it on your social, get a lot of upvotes using that source but that wouldn't exactly mean it's a highly anticipated feature
comment in response to post
The docs should serve the people and the people see it as a highly viable option
comment in response to post
I know it's not the best metric but it still tells us *something*. The longer this stays unsolved and this ain't mentioned in the docs the more it will look like you are against it for some weird reasons that are *not* understood by the community
comment in response to post
I have no skin in the game and I don't care all that much but I just checked npm download stats and Vite React plugin has 5 million weekly downloads. From my bystander's PoV, it looks u (as in, the React team) are underplaying its importance and the kind of setup *a lot* of people want
comment in response to post
Just finally open the kitchen for visitors!
comment in response to post
there is an open PR that handles some of the cases but it's waiting for review: github.com/microsoft/Ty...
comment in response to post
Switch/case was faster in this codebase the last time i checked, this is a smaller one though so perhaps i should benchmark this again.
comment in response to post
pure nepotism, I just happen to know the right people
comment in response to post
comment in response to post
🇵🇱🤝🇮🇹
comment in response to post
Remember that this is just a PR at this stage 😉
comment in response to post
Im ok with getting some credits for landing some bugs fixes and new features though :P
comment in response to post
To be fair, I only maintain (currently not too actively) Changesets. It has been created by Thinkmill+Atlassian
comment in response to post
comment in response to post
🤔
comment in response to post
Ye, right - this is even more cursed 😝
comment in response to post
JS class private fields trivia #2 - they are unique symbol-likes though so you can redefine them even in such nested classes and that leads to an interesting object display in Chrome
comment in response to post
Partly because of that the repo isnt using Prettier but dprint ;p i dont experience a lot of IDE slowdown when working with this and the repo is using eslint (and TS LSP ofc)
comment in response to post
When working with this file I actually love that it’s all in one file, it’s easy to grep it and jump between locations, most of things are already available in scope. It’s nice
comment in response to post
I think to some extent the reasons are historical - it was written using legacy TS modules/namespaces and it wouldnt be great for perf if things would incur property lookup costs all over the place. Since then the codebase has been migrated to use ES modules though
comment in response to post
Is there a technical reason to split up big files? ;p
comment in response to post
you can find the relevant source code here: github.com/microsoft/Ty...
comment in response to post
Since few versions the same applies to intersections of arrays and tuples (all members have to be arrays/tuples to get some special treatment). Not that u should have intersections of arrays/tuples though ;p
comment in response to post
Arrays and tuples are specialcased in the compiler so they can work this way
comment in response to post
Basically K in such mapped type has an implied constraint of `extends number | `${number}`` to allow this. It “discards” other keys
comment in response to post
When the mapped type is homomorphic it iterates over shape of the array rather than over its all keys that include prototype methods etc. It’s much more useful than the alternative ;p
comment in response to post
@joshuakgoldberg.com hi!