Boolean filter improvement alternative: TS upgrade (#4840)

* upgrade typescript and use new feature

* fix: typing error
zio/stable
Dmitrii Kartashev 2024-07-25 19:31:59 -04:00 committed by GitHub
parent 50769b0b6f
commit 4437b9a557
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 10 deletions

View File

@ -270,7 +270,7 @@
"react-scripts": "^5.0.1",
"react-test-renderer": "18.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.3.3",
"typescript": "^5.5.4",
"url-loader": "^4.1.1",
"webpack": "^5.75.0",
"webpack-bundle-analyzer": "^4.10.1",

View File

@ -74,7 +74,9 @@ function DialogContent({
const onPressAudience = (setting: ThreadgateSetting) => {
// remove nobody
let newSelected = draft.filter(v => v.type !== 'nobody')
let newSelected: ThreadgateSetting[] = draft.filter(
v => v.type !== 'nobody',
)
// toggle
const i = newSelected.findIndex(v => isEqual(v, setting))
if (i === -1) {

View File

@ -375,11 +375,11 @@ export function usePostFeedQuery(
}
return undefined
})
.filter(<T>(n?: T): n is T => Boolean(n)),
.filter(n => !!n),
}
return feedPostSlice
})
.filter(<T>(n?: T): n is T => Boolean(n)),
.filter(n => !!n),
})),
],
}

View File

@ -33,6 +33,6 @@ export function threadgateViewToSettings(
}
return setting
})
.filter(<T>(n?: T): n is T => Boolean(n))
.filter(n => !!n)
return settings
}

View File

@ -119,7 +119,7 @@ function LoadMore({
}
return loadMoreItem
})
.filter(<T,>(n?: T): n is T => Boolean(n))
.filter(n => !!n)
}, [item.items, moderationOpts])
if (items.length === 0) return null

View File

@ -21378,10 +21378,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"
typescript@^5.3.3:
version "5.3.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37"
integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==
typescript@^5.5.4:
version "5.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==
ua-parser-js@^0.7.33:
version "0.7.35"