Event JSON
{
"id": "e0d731b94337a5fe63afc8705ecd3b906fded5616058ff75150cbe3e3439e828",
"pubkey": "bb1742d1b321126a78c9a65acb9b810a49693c1b76b6446ae059fc3ff0cc2bf2",
"created_at": 1719067786,
"kind": 1,
"tags": [
[
"p",
"692d9d8fb6c5db3d114c21513be89063e8ee0d14f89d35103c8f1b7d40a116a7"
],
[
"p",
"bf5bda1ed179ed5a3a439950d238c9b3ac64d10a0b2a87a0c34c350d8455b6fd"
],
[
"e",
"9ef941bdeb7154ba9c9e191c9be759f2c20d9e833738f2e99d38704d3e4f3b9a",
"",
"root"
],
[
"p",
"ceee9d7e6705946321b940eb4ec4db738c18362d2ac26d89c9eaaf9269c7fe0b"
],
[
"e",
"6b88536a9da351f76698c7b653a9f85152130a18b378583c34644c09eb6e03d4",
"",
"reply"
],
[
"p",
"bb1742d1b321126a78c9a65acb9b810a49693c1b76b6446ae059fc3ff0cc2bf2"
],
[
"proxy",
"https://techhub.social/@develwithoutacause/112660826457206529",
"web"
],
[
"proxy",
"https://techhub.social/users/develwithoutacause/statuses/112660826457206529",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://techhub.social/users/develwithoutacause/statuses/112660826457206529",
"pink.momostr"
],
[
"expiration",
"1721659789"
]
],
"content": "Mainly being explicit that a cast is happening.\n\nUsually `getData\u003cstring\u003e('key')` syntax is constrained such that `string` is validated to be correct. If the data was actually a `number`, I would expect TS to stop me with an error. I think this also applies with `const data: string = getData('key');`. The type `string` causes `getData`'s return type to match automatically in a potentially incorrect way.\n\nUsing a cast like `getData('key') as string` makes it clear to the developer that \"You are asserting the result is `string`, whether or not it actually is.\"\n\nIf I were reviewing this code, it would also stand out as something which may justify a runtime check (`typeof data === 'string`) in case there's ambiguity in a way I'd be unlikely to notice for `getData\u003cstring\u003e`.\n\nThis is actually a part of the Google style guide, though it does not include justification unfortunately: https://google.github.io/styleguide/tsguide.html#return-type-only-generics",
"sig": "fe370f2717cfb06429fc378a32ee68a8c3a10f9e748a88fe673e2890df8e24cea0ce197e8332d11572016cb99b0488a39c49275c56d5e647418fa674dcc57fc2"
}