The Nineteenth Byte

The Nineteenth Byte: General discussion for codegolf.stackexc...
Mar 29, 2023 07:24
@user tons of deno packages support node thanks to an official build tool
Mar 29, 2023 07:14
i guess you could do a quick search in issues for some of the more obscure features (if any) if there are any they still havent implemented or something
Mar 29, 2023 07:14
@hyper-neutrino deno should be very stable nowadays, discordeno... is full-featured enough for me but i dont use anywhere near all of discord's API so i cant really say whether itll cover your usecase
Mar 29, 2023 04:19
@lyxal yeah, it's mostly because i figured I'm not very active of a contributor anymore... like i don't mind contributing but i'm not active here enough to know what needs doing
Mar 28, 2023 19:36
this is why all the cool kids use discordeno
Mar 28, 2023 19:33
but i mean... if it ain't broke anymore, don't fix it, lol
Mar 28, 2023 19:33
yeah... it's weird that djs issues didn't mention anything about this though
Mar 28, 2023 19:32
for performance? probably .bind(this), by a very narrow margin
Mar 28, 2023 19:29
i'm pretty sure djs has had these typings for years though
Mar 28, 2023 19:29
huge thonk
Mar 28, 2023 19:27
but i don't feel like that's possible because, while they're both the only callbacks with != 1 argument... both of them have two arguments
Mar 28, 2023 19:26
this error does sometimes happen when the second argument is used as the discriminator
Mar 28, 2023 19:25
cuz it's definitely working for all the other .on which is kinda weird
Mar 28, 2023 19:25
@Bbrk24 not sure, unfortunately i don't have the typings for discord.js memorized - what does the type parameter get inferred as?
Mar 28, 2023 19:24
if they don't know about Object#constructor i suspect they wouldn't even think of using constructor as a key
Mar 28, 2023 19:24
well
Mar 28, 2023 19:24
like, no offense but that's a lot of hoops you'd have to jump through to intentionally trigger that error
Mar 28, 2023 19:23
@Bbrk24 that's fair but who in their right mind would be explicitly accessing the field called constructor with a literal-typed string
Mar 28, 2023 19:22
function coerceSetting<T extends keyof IServerSettings>(
  key: T,
  value: string
): IServerSettings[T] | undefined
function coerceSetting(key: keyof IServerSettings, value: string): IServerSettings[keyof IServerSettings] | undefined {
}
Mar 28, 2023 19:21
that's fair... but it's not like constructor?: never does much for type safety... does it?
Mar 28, 2023 19:20
@Bbrk24 hm?
Mar 28, 2023 19:19
@Bbrk24 this is trivially solvable (although not type-safe) by using a single overload
Mar 28, 2023 19:18
yeah typescript kinda doesn't do inheritance in general... apart from what it must, of course (class extends foo)
Mar 28, 2023 19:17
for other cases yet ("key1" | "key2" it will type-error anyway)
Mar 28, 2023 19:17
for many other cases (e.g. string), it's impossible to check them all
Mar 28, 2023 19:17
@Bbrk24 beacuse typescript doesn't go through each possible type parameter because in many (if not most) cases, it's too slow
Mar 28, 2023 19:16
@Bbrk24 it doesn't let you, yes, but there is no way to mark a type as not having extra keys in typescript
Mar 28, 2023 19:15
@ASCII-only wait wrong type, that's the type for Object.entries...
Mar 28, 2023 19:13
Mar 28, 2023 19:13
hence, they are absolutely needed
Mar 28, 2023 19:13
@Bbrk24 also not type safe.
Mar 28, 2023 19:13
@Bbrk24 yes, because this is not type safe.
Mar 28, 2023 19:11
if a has literally any property at all then 'foo' in x works perfectly
Mar 28, 2023 19:11
@ASCII-only although this is more because of {} acting funny than anything
Mar 28, 2023 19:10
@Bbrk24 nope, they can't.
Mar 28, 2023 19:09
i have a suspicion the reason why it does this is because it's not of type A | B
Mar 28, 2023 19:09
well
Mar 28, 2023 19:09
Mar 28, 2023 19:06
assuming B has the key 'key' and A doesn't
Mar 28, 2023 19:05
@Bbrk24 no, because if it's already an A | B it narrows it to B.
Mar 28, 2023 19:04
(if ('key' in obj))
Mar 28, 2023 19:03
it's easy enough to check whether an object is B
Mar 28, 2023 19:03
i mean
Mar 28, 2023 19:02
@Bbrk24 this is why module augmentation is a thing in ts.
Mar 28, 2023 18:56
> Emit more compliant, but verbose and less performant JavaScript for iteration.
Mar 28, 2023 18:56
fun fact: the flag description even says why it's not the default behavior
Mar 28, 2023 18:56
Mar 28, 2023 18:55
@Bbrk24 yes, and downlevelIteration is the flag that uses the correct behavior...
Mar 28, 2023 18:54
@Bbrk24 downlevelIteration moment
Mar 28, 2023 18:51
yeah ... is what, ES6?