Common Naming Scheme for Intermediate Schemas in TypeScript
Is there a common naming scheme for any of the intermediate schemas, like
User1User1 and User2User2 in this snippet?import * as B from "effect/Brand"
const UserId = B.nominal<UserId>()
type UserId = B.Branded<string, 'UserId'>
const UserId$ = pipe(S.String, S.fromBrand(ItemId))
type UserId$ = typeof UserId$
const UserEncoded$ = S.Struct({
name: S.String,
id: S.String,
friends: S.Array(S.String),
})
const User1$ = S.Struct({
name: S.String,
id: UserId$,
friends: S.Array(UserId$)
})
const User2$: User2$ = S.Struct({
name: S.String,
id: UserId$,
friends: S.Array(S.suspend((): User2$ => User2$))
})
const UserFields = {
name: S.String,
id: UserId$,
friends: S.Array(S.suspend((): S.Schema<User, User3Encoded> => User))
} as const
class User extends S.Class<User>('User3')(UserFields) {
addFriend(user: User) { }
}
type User1$ = typeof User1$
type User1 = S.Schema.Type<User1$>
type User2 = Omit<User1, 'friends'> & { friends: readonly User2[] }
type User2Encoded = Omit<User2, 'id' | 'friends'> & { id: string, friends: readonly User2Encoded[] }
type User2$ = S.Schema<User2, User2Encoded>
type User3Type = Omit<User1, 'friends'> & { friends: readonly User[] }
type User3Encoded = Omit<User3Type, 'id' | 'friends'> & { id: string, friends: readonly User3Encoded[] }import * as B from "effect/Brand"
const UserId = B.nominal<UserId>()
type UserId = B.Branded<string, 'UserId'>
const UserId$ = pipe(S.String, S.fromBrand(ItemId))
type UserId$ = typeof UserId$
const UserEncoded$ = S.Struct({
name: S.String,
id: S.String,
friends: S.Array(S.String),
})
const User1$ = S.Struct({
name: S.String,
id: UserId$,
friends: S.Array(UserId$)
})
const User2$: User2$ = S.Struct({
name: S.String,
id: UserId$,
friends: S.Array(S.suspend((): User2$ => User2$))
})
const UserFields = {
name: S.String,
id: UserId$,
friends: S.Array(S.suspend((): S.Schema<User, User3Encoded> => User))
} as const
class User extends S.Class<User>('User3')(UserFields) {
addFriend(user: User) { }
}
type User1$ = typeof User1$
type User1 = S.Schema.Type<User1$>
type User2 = Omit<User1, 'friends'> & { friends: readonly User2[] }
type User2Encoded = Omit<User2, 'id' | 'friends'> & { id: string, friends: readonly User2Encoded[] }
type User2$ = S.Schema<User2, User2Encoded>
type User3Type = Omit<User1, 'friends'> & { friends: readonly User[] }
type User3Encoded = Omit<User3Type, 'id' | 'friends'> & { id: string, friends: readonly User3Encoded[] }