Add Resolve<T> utility type
This commit is contained in:
@ -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<typeof accountSchema>;
|
||||
type Account = Resolve<z.infer<typeof accountSchema>>;
|
||||
|
||||
export { accountSchema, type Account };
|
||||
@ -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<typeof statusSchema>;
|
||||
type Status = Resolve<z.infer<typeof statusSchema>>;
|
||||
|
||||
export { statusSchema, type Status };
|
||||
7
app/soapbox/utils/types.ts
Normal file
7
app/soapbox/utils/types.ts
Normal file
@ -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<T> = Pick<T, keyof T>;
|
||||
|
||||
export type { Resolve };
|
||||
Reference in New Issue
Block a user