Skip to content

Commit 7f3a1a5

Browse files
committed
fix: improved type saftey
1 parent 8c32220 commit 7f3a1a5

3 files changed

Lines changed: 42 additions & 41 deletions

File tree

platforms/metagram/src/lib/fragments/UploadedPostView/UploadedPostView.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<script lang="ts">
22
import { Cross } from '$lib/icons';
3+
import type { Image } from '$lib/types';
34
import { cn } from '$lib/utils';
45
import type { HTMLAttributes } from 'svelte/elements';
56
6-
interface IImage {
7-
url: string;
8-
alt: string;
9-
}
107
118
interface IUploadedPostViewProps extends HTMLAttributes<HTMLElement> {
12-
images: IImage[];
9+
images: Image[];
1310
width?: string;
1411
height?: string;
1512
callback: (i: number) => void;

platforms/metagram/src/lib/store/store.svelte.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PostData } from "$lib/types";
1+
import type { Image, PostData } from "$lib/types";
22

33
export const isNavigatingThroughNav = $state({
44
value: false,
@@ -16,10 +16,9 @@ export const selectedPost: { value: PostData | null } = $state({
1616
value: null,
1717
});
1818

19-
export const uploadedImages: { value: { url: string; alt: string }[] | null } =
20-
$state({
21-
value: null,
22-
});
19+
export const uploadedImages: { value: Image[] | null } = $state({
20+
value: null,
21+
});
2322

2423
export const audience: { value: string } = $state({
2524
value: "Everyone",
Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1-
import type { SVGAttributes } from 'svelte/elements';
1+
import type { SVGAttributes } from "svelte/elements";
22

33
export interface ISvgProps extends SVGAttributes<SVGElement> {
4-
size?: number | string;
5-
color?: string;
4+
size?: number | string;
5+
color?: string;
66
}
77

88
export type CommentType = {
9-
commentId: string;
10-
name: string;
11-
userImgSrc: string;
12-
comment: string;
13-
isUpVoted: boolean;
14-
isDownVoted: boolean;
15-
upVotes: number;
16-
time: string;
17-
replies: CommentType[];
9+
commentId: string;
10+
name: string;
11+
userImgSrc: string;
12+
comment: string;
13+
isUpVoted: boolean;
14+
isDownVoted: boolean;
15+
upVotes: number;
16+
time: string;
17+
replies: CommentType[];
1818
};
1919

2020
export type PostData = {
21-
id: string;
22-
avatar: string;
23-
userId: string;
24-
username: string;
25-
imgUris: string[];
26-
caption: string;
27-
time: string;
28-
count: {
29-
likes: number;
30-
comments: number;
31-
};
21+
id: string;
22+
avatar: string;
23+
userId: string;
24+
username: string;
25+
imgUris: string[];
26+
caption: string;
27+
time: string;
28+
count: {
29+
likes: number;
30+
comments: number;
31+
};
3232
};
3333

3434
export type userProfile = {
35-
userId: string;
36-
username: string;
37-
avatar: string;
38-
totalPosts: number;
39-
followers: number;
40-
following: number;
41-
userBio: string;
42-
posts: PostData[];
35+
userId: string;
36+
username: string;
37+
avatar: string;
38+
totalPosts: number;
39+
followers: number;
40+
following: number;
41+
userBio: string;
42+
posts: PostData[];
43+
};
44+
45+
export type Image = {
46+
url: string;
47+
alt: string;
4348
};

0 commit comments

Comments
 (0)