Skip to content

Commit

Permalink
Boolean filter improvement alternative: TS upgrade (bluesky-social#4840)
Browse files Browse the repository at this point in the history
* upgrade typescript and use new feature

* fix: typing error
  • Loading branch information
Faithfinder authored Jul 25, 2024
1 parent 50769b0 commit 4437b9a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/components/dialogs/ThreadgateEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/state/queries/post-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})),
],
}
Expand Down
2 changes: 1 addition & 1 deletion src/state/queries/threadgate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export function threadgateViewToSettings(
}
return setting
})
.filter(<T>(n?: T): n is T => Boolean(n))
.filter(n => !!n)
return settings
}
2 changes: 1 addition & 1 deletion src/view/screens/Search/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4437b9a

Please sign in to comment.