Adding comment to object key
Hello! What would be the right way to add comments to an object's key, like you do with
/** */
?
I tried this, but it didn't work:
22 Replies
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Thank you! Good to know 👍
Hmm
@ssalbdivad looks like a regression since v1
@Dimava I remember you had opened an issue related to this but I know in the general case it is not possible as @AlexWayne mentions, especially given the addition of parsed syntax for e.g. index signatures within keys
ik general case is not possible but non-optionals did work well
type.for (what was it again? I still forget it every time) may be better for those
declare.type
If it is possible to implement a solution that preserves them for required keys without sacrificing perf and ideally without duplicating a ton of code I would be open to merging that, it's just not something I want to commit to broadly since TS's rules around it aren't necessarily clear or well-documented either
IIRC there was only a single working rule and it was "
[K in keyof T as X]
should use clean K
in X
when required "
Gonna check how your code worksYeah it has to be a homomorphic mapped type but you can see why I'm not just not very keen on the idea of making guarantees around behavior like this based on the extent of what TS has officially guaranteed about it
This should work, how do I bench
pnpm benchObject
My intuition is that is not great since it adds an extra intersection to every object type
And that EscapeToken comparison is not trivial not always correct (though it would still be an improvement to get it most of the time)+2.5%
That's not bad, I'd want to do some more testing though since those aren't really comprehensive enough on their own to give me a lot of confidence about a change of this scope.
What about
pnpm attest stats
before and after the changehm
Yeah that's less encouraging plus what are the errors
Okay, 4519 is my best result
That's 7.6% up