Convert features/status/index to typescript (pretty much)

This commit is contained in:
Alex Gleason 2022-04-04 14:17:24 -05:00
parent c51441c026
commit fdb44d615d
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
5 changed files with 9 additions and 9 deletions

View file

@ -16,7 +16,7 @@ const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
let id = 0;
export interface MenuItem {
action: React.EventHandler<React.KeyboardEvent | React.MouseEvent>,
action?: React.EventHandler<React.KeyboardEvent | React.MouseEvent>,
middleClick?: React.EventHandler<React.MouseEvent>,
text: string,
href?: string,

View file

@ -4,7 +4,6 @@ import PTRComponent from 'react-simple-pull-to-refresh';
import { Spinner } from 'soapbox/components/ui';
interface IPullToRefresh {
children: JSX.Element & React.ReactNode,
onRefresh?: () => Promise<any>
}
@ -12,7 +11,7 @@ interface IPullToRefresh {
* PullToRefresh:
* Wrapper around a third-party PTR component with Soapbox defaults.
*/
const PullToRefresh = ({ children, onRefresh, ...rest }: IPullToRefresh) => {
const PullToRefresh: React.FC<IPullToRefresh> = ({ children, onRefresh, ...rest }): JSX.Element => {
const handleRefresh = () => {
if (onRefresh) {
return onRefresh();
@ -33,7 +32,8 @@ const PullToRefresh = ({ children, onRefresh, ...rest }: IPullToRefresh) => {
resistance={2}
{...rest}
>
{children}
{/* This thing really wants a single JSX element as its child (TypeScript), so wrap it in one */}
<>{children}</>
</PTRComponent>
);
};

View file

@ -98,12 +98,12 @@ const toServerSideType = (columnType: string): string => {
}
};
type FilterContext = { contextType: string };
type FilterContext = { contextType?: string };
export const getFilters = (state: RootState, { contextType }: FilterContext) => {
export const getFilters = (state: RootState, query: FilterContext) => {
return state.filters.filter((filter): boolean => {
return contextType
&& filter.get('context').includes(toServerSideType(contextType))
return query?.contextType
&& filter.get('context').includes(toServerSideType(query.contextType))
&& (filter.get('expires_at') === null
|| Date.parse(filter.get('expires_at')) > new Date().getTime());
});
@ -132,7 +132,7 @@ export const regexFromFilters = (filters: ImmutableList<ImmutableMap<string, any
}).join('|'), 'i');
};
type APIStatus = { id: string, username: string };
type APIStatus = { id: string, username?: string };
export const makeGetStatus = () => {
return createSelector(