ruto on Nostr: TypeScriptで`xs: (string | null)[]`のとき、`xs.filter(x => ...
TypeScriptで`xs: (string | null)[]`のとき、`xs.filter(x => x)`が`string[]`になって欲しい。
`function isNotNull<T>(x: T | null): x is T`を定義して`xs.filter(isNotNull)`とすればいけるけど。
Published at
2023-08-18 08:09:52Event JSON
{
"id": "f96c8324fcdcdd5f4a2d35dc308ee97dd98663fefb2c25464a5a1d951d15d02d",
"pubkey": "2888961a564e080dfe35ad8fc6517b920d2fcd2b7830c73f7c3f9f2abae90ea9",
"created_at": 1692346192,
"kind": 1,
"tags": [],
"content": "TypeScriptで`xs: (string | null)[]`のとき、`xs.filter(x =\u003e x)`が`string[]`になって欲しい。\n`function isNotNull\u003cT\u003e(x: T | null): x is T`を定義して`xs.filter(isNotNull)`とすればいけるけど。",
"sig": "d7a5655f7adc3daaf200f7c37bede6f2b3644890f0480fbaf1cfe6850940da68de1f4b29168ad78f0d556ba5100d3bb876b51c16a02c0d0fcae9ed2ae70374aa"
}