interface: fix tsc errors

This commit is contained in:
Liam Fitzgerald 2021-08-30 10:54:09 +10:00
parent 95b24c8a34
commit 83f0b4c794
6 changed files with 17 additions and 14 deletions

View File

@ -36,7 +36,7 @@ export function GroupifyForm(props: GroupifyFormProps) {
name,
values.group?.toString() || undefined
));
let mod = association['app-name'];
let mod: string = association['app-name'];
if (association?.metadata?.config && 'graph' in association.metadata.config) {
mod = association.metadata.config.graph as AppName;
}

View File

@ -26,7 +26,7 @@ export function Resource(props: ResourceProps): ReactElement {
const notificationsCount = useHarkState(state => state.notificationsCount);
const associations = useMetadataState(state => state.associations);
const contacts = useContactState(state => state.contacts);
let app = association['app-name'];
let app: string = association['app-name'];
if (association?.metadata?.config && 'graph' in association.metadata.config) {
app = association.metadata.config.graph as AppName;
}

View File

@ -65,7 +65,7 @@ type ResourceSkeletonProps = {
export function ResourceSkeleton(props: ResourceSkeletonProps): ReactElement {
const { association, baseUrl, children } = props;
let app = association['app-name'];
let app: string = association['app-name'];
if (association?.metadata?.config && 'graph' in association.metadata.config) {
app = association.metadata.config.graph as AppName;
}

View File

@ -2,7 +2,7 @@ import _ from 'lodash';
import React, { useRef, ReactNode } from 'react';
import urbitOb from 'urbit-ob';
import { Icon, Row, Box, Text, BaseImage } from '@tlon/indigo-react';
import { Association, cite, AppName } from '@urbit/api';
import { Association, cite } from '@urbit/api';
import { HoverBoxLink } from '~/views/components/HoverBox';
import { Sigil } from '~/logic/lib/sigil';
import { useTutorialModal } from '~/views/components/useTutorialModal';
@ -176,9 +176,9 @@ export const SidebarAssociationItem = React.memo((props: {
const { association, selected } = props;
const title = getItemTitle(association) || '';
const appName = association?.['app-name'];
let mod = appName;
let mod: string = appName;
if (association?.metadata?.config && 'graph' in association.metadata.config) {
mod = association.metadata.config.graph as AppName;
mod = association.metadata.config.graph ;
}
const rid = association?.resource;
const groupPath = association?.group;

View File

@ -1,5 +1,5 @@
import { AppName, Path, Poke, uxToHex, PatpNoSig } from '../lib';
import { Association, Metadata, MetadataUpdate, MetadataUpdateAdd, MetadataUpdateRemove, MetadataEditField, MetadataUpdateEdit } from './types';
import { Path, Poke, uxToHex, PatpNoSig } from '../lib';
import { MdAppName, Association, Metadata, MetadataUpdate, MetadataUpdateAdd, MetadataUpdateRemove, MetadataEditField, MetadataUpdateEdit } from './types';
export const METADATA_UPDATE_VERSION = 2;
@ -11,7 +11,7 @@ export const metadataAction = <T extends MetadataUpdate>(data: T, version: numbe
export const add = (
ship: PatpNoSig,
appName: AppName,
appName: MdAppName,
resource: Path,
group: Path,
title: string,
@ -44,10 +44,10 @@ export const add = (
export { add as metadataAdd };
export const remove = (
appName: AppName,
appName: MdAppName,
resource: string,
group: string
): Poke<MetadataUpdateRemove> => metadataAction({
): Poke<MetadataUpdateRemove> => metadataAction<MetadataUpdateRemove>({
remove: {
group,
resource: {
@ -62,7 +62,7 @@ export { remove as metadataRemove };
export const edit = (
association: Association,
edit: MetadataEditField
): Poke<MetadataUpdateEdit> => metadataAction({
): Poke<MetadataUpdateEdit> => metadataAction<MetadataUpdateEdit>({
edit: {
group: association.group,
resource: {
@ -84,7 +84,7 @@ export const update = (
): Poke<MetadataUpdateAdd> => {
const metadata = { ...association.metadata, ...newMetadata };
metadata.color = uxToHex(metadata.color);
return metadataAction({
return metadataAction<MetadataUpdateAdd>({
add: {
group: association.group,
resource: {

View File

@ -1,5 +1,7 @@
import { Path, Patp } from '../lib';
export type MdAppName = 'groups' | 'graph';
export type MetadataUpdate =
MetadataUpdateInitial
| MetadataUpdateAdd
@ -26,6 +28,7 @@ export type MetadataUpdateUpdate = {
export interface MetadataUpdateEdit {
edit: {
resource: MdResource;
group: string;
edit: MetadataEditField;
}
}
@ -41,7 +44,7 @@ export type MetadataUpdateRemove = {
export interface MdResource {
resource: string;
'app-name': 'groups' | 'graph';
'app-name': MdAppName;
}
export interface MetadataUpdatePreview {