Dusty Pomerleau on Nostr: TypeScript’s `document.activeElement` returns `Element`. If the `Element` is an ...
TypeScript’s `document.activeElement` returns `Element`. If the `Element` is an `HTMLElement` you have to cast it back every time you use a method not available on `Element` (or ignore/expect the error TS gives when you call `activeElement()`).
In Rust, we would fix this by returning `impl Element`. Is there any equivalent in TS?
#TypeScript #RustLang
Published at
2024-03-19 06:53:14Event JSON
{
"id": "2d271891d42a99cf73039eb1b71d6beb1d8fd6c5a47935ce979eb98b8ce86d10",
"pubkey": "5bdfe5c3188a24f76efd37648930d8ada3e458961d03b2e0d62596d4f76e4778",
"created_at": 1710831194,
"kind": 1,
"tags": [
[
"t",
"typescript"
],
[
"t",
"rustlang"
],
[
"proxy",
"https://fosstodon.org/users/dpom/statuses/112121033179350889",
"activitypub"
]
],
"content": "TypeScript’s `document.activeElement` returns `Element`. If the `Element` is an `HTMLElement` you have to cast it back every time you use a method not available on `Element` (or ignore/expect the error TS gives when you call `activeElement()`).\n\nIn Rust, we would fix this by returning `impl Element`. Is there any equivalent in TS?\n\n#TypeScript #RustLang",
"sig": "7037c6c6a19196908c19a9d92aa91bd83ada62400d9726359faabe8c215a5507ad6d50f2c8020173dbd4ebd8fae509f02634a93841b5164c920d59fe1753b09a"
}