it is so dumb to me that javascript nor typescript...
# random
h
it is so dumb to me that javascript nor typescript have the ability create class constructors that automatically assign the values of identically defined properties. (aka kotlin's delegation). the lack thereof is perhaps the most unnecessarily verbose aspect of js/ts. e.g.
Copy code
interface Baz {
    foo
    bar
}

class Bar implements Baz {
    foo
    bar

    constructor(baz: Baz) {
        this.foo = baz.foo
        this.bar = baz.bar
    }
}
that shit becomes so long and verbose in some models
h
­čĹć 1
h
not exactly what i meant. i mean that if you are writing a constructor for a class that extends or implements an interface, you have to decide whether or not to make a constructor param which is an object of that type, and then manually set all the properties, or you put all that type's properties in the constructor, and then have to manually distribute them when calling the constructor.
h
Oh. Now I see. You weren't talking about Kotlin constructors. Sorry for the noise.
h
yeah, sorry as well about the confusion. in kotlin you can achieve what i want in js/ts via delegation.
Copy code
data class Bar(val bib: Int)

data class Foo(bar: Bar, baz: Baz): Bar by bar

print(Foo(Bar(7)).bib)
// 7
you can see how many lines that might save if
Bar
has 10 fields, like in the case of a
User
class or something
l
Whooh, I already forgot about this feature. Thanks for putting it up! ­čÖé