Finished migrating ll short-url helpers to TS

This commit is contained in:
Alejandro Celaya
2020-08-30 09:59:14 +02:00
parent c0f5d9c12c
commit 4b33d39d44
30 changed files with 483 additions and 499 deletions

View File

@@ -27,14 +27,14 @@ export type SelectedServer = RegularServer | NotFoundServer | null;
export type ServersMap = Record<string, ServerWithId>;
export const hasServerData = (server: ServerData | NotFoundServer | null): server is ServerData =>
export const hasServerData = (server: SelectedServer | ServerData): server is ServerData =>
!!(server as ServerData)?.url && !!(server as ServerData)?.apiKey;
export const isReachableServer = (server: SelectedServer): server is ReachableServer =>
!!server?.hasOwnProperty('printableVersion');
export const isServerWithId = (server: SelectedServer | ServerWithId): server is ServerWithId =>
!!server?.hasOwnProperty('id');
export const isReachableServer = (server: SelectedServer): server is ReachableServer =>
!!server?.hasOwnProperty('printableVersion');
export const isNotFoundServer = (server: SelectedServer): server is NotFoundServer =>
!!server?.hasOwnProperty('serverNotFound');

View File

@@ -14,6 +14,7 @@ const notFoundServerType = PropTypes.shape({
serverNotFound: PropTypes.bool.isRequired,
});
/** @deprecated Use SelectedServer type instead */
export const serverType = PropTypes.oneOfType([
regularServerType,
notFoundServerType,