Bart Louwers on Nostr: I don't understand. ```js class Base { bla() { console.log("base"); } }; class ...
I don't understand.
```js
class Base {
bla() {
console.log("base");
}
};
class Derived extends Base {
bla() {
console.log("derived");
}
};
/**
* @template {Base} T
* @param {T} base
*/
function fun(base) {
base.bla();
}
fun(new Base());
fun(new Derived());
/**
*
* @param {typeof Base} cls
*/
function makeBase(cls) {
return new cls();
}
makeBase(Base).bla();
makeBase(Derived).bla();
```
Published at
2024-08-28 19:39:04Event JSON
{
"id": "60297f32b496b4e3a573326e87d06ab42db1994b2054785c7ad3eb5af00af001",
"pubkey": "708c2185baba421f00fcdb677eb12874ad9ac79b0a96d6369e7505353079cbb0",
"created_at": 1724873944,
"kind": 1,
"tags": [
[
"p",
"0bcb4fea58ca0749444278a4850b964fba08d7aee656cb583838bc703bec7759"
],
[
"e",
"9c9e371164f652d7170ce0bcbeca41e8aea43da1fb3809183e3048e36e3c0bc1",
"",
"root",
"0bcb4fea58ca0749444278a4850b964fba08d7aee656cb583838bc703bec7759"
],
[
"proxy",
"https://floss.social/@bart/113041338811199717",
"web"
],
[
"proxy",
"https://floss.social/users/bart/statuses/113041338811199717",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://floss.social/users/bart/statuses/113041338811199717",
"pink.momostr"
],
[
"-"
]
],
"content": "I don't understand. \n\n```js\nclass Base {\n bla() {\n console.log(\"base\");\n }\n};\n\nclass Derived extends Base {\n bla() {\n console.log(\"derived\");\n }\n};\n\n/**\n * @template {Base} T\n * @param {T} base\n */\nfunction fun(base) {\n base.bla();\n}\n\nfun(new Base());\nfun(new Derived());\n\n/**\n * \n * @param {typeof Base} cls \n */\nfunction makeBase(cls) {\n return new cls();\n}\n\nmakeBase(Base).bla();\nmakeBase(Derived).bla();\n```",
"sig": "67a0c3ce46ef75088a2a2054021a4ba388f807c61338e78f3d097766057a14c1cd5e84308cd972a500f43533ae151a9e0ac2a84bcfc8fc6a25f6d2f1fd7ce095"
}