diff --git a/app/soapbox/schemas/account.ts b/app/soapbox/schemas/account.ts index f0fdf4887..6c41bebc4 100644 --- a/app/soapbox/schemas/account.ts +++ b/app/soapbox/schemas/account.ts @@ -7,6 +7,8 @@ import { unescapeHTML } from 'soapbox/utils/html'; import { customEmojiSchema } from './custom-emoji'; import { contentSchema, filteredArray, makeCustomEmojiMap } from './utils'; +import type { Resolve } from 'soapbox/utils/types'; + const avatarMissing = require('assets/images/avatar-missing.png'); const headerMissing = require('assets/images/header-missing.png'); @@ -142,6 +144,6 @@ const accountSchema = baseAccountSchema.extend({ moved: baseAccountSchema.transform(transformAccount).nullable().catch(null), }).transform(transformAccount); -type Account = z.infer; +type Account = Resolve>; export { accountSchema, type Account }; \ No newline at end of file diff --git a/app/soapbox/schemas/status.ts b/app/soapbox/schemas/status.ts index de06ecb98..accd31a6a 100644 --- a/app/soapbox/schemas/status.ts +++ b/app/soapbox/schemas/status.ts @@ -16,6 +16,8 @@ import { pollSchema } from './poll'; import { tagSchema } from './tag'; import { contentSchema, dateSchema, filteredArray, makeCustomEmojiMap } from './utils'; +import type { Resolve } from 'soapbox/utils/types'; + const statusPleromaSchema = z.object({ emoji_reactions: filteredArray(emojiReactionSchema), event: eventSchema.nullish().catch(undefined), @@ -144,6 +146,6 @@ const statusSchema = baseStatusSchema.extend({ }; }).transform(transformStatus); -type Status = z.infer; +type Status = Resolve>; export { statusSchema, type Status }; \ No newline at end of file diff --git a/app/soapbox/utils/types.ts b/app/soapbox/utils/types.ts new file mode 100644 index 000000000..31eacd481 --- /dev/null +++ b/app/soapbox/utils/types.ts @@ -0,0 +1,7 @@ +/** + * Resolve a type into a flat POJO interface if it's been wrapped by generics. + * https://gleasonator.com/@alex/posts/AWfK4hyppMDCqrT2y8 + */ +type Resolve = Pick; + +export type { Resolve }; \ No newline at end of file