本文整理汇总了TypeScript中tcomb.list函数的典型用法代码示例。如果您正苦于以下问题:TypeScript list函数的具体用法?TypeScript list怎么用?TypeScript list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了list函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
okTake<TcombChatMember[]>(t, sources, (chatMembers) => {
t.ok(tc.list(ChatMember).is(tc.list(ChatMember)(chatMembers)), 'chat members satisfies typecheck')
chatMembers.forEach((chatMember: any) => {
t.ok(chatMember.hasOwnProperty('user'), 'chat member has property user')
t.ok(chatMember.hasOwnProperty('status'), 'chat member has property status')
})
t.end()
})
示例2:
export const GameHighScore = t.struct<TcombGameHighScore>({
position: t.Number,
user: User,
score: t.Number
})
export interface TcombGameHighScore {
position: number
user: TcombUser
score: number
}
export const Game = t.struct<TcombGame>({
title: t.String,
description: t.String,
photo: t.list(m.PhotoSize),
text: t.maybe(t.String),
text_entities: t.maybe(t.list(MessageEntity)),
animation: t.maybe(m.Animation)
})
export interface TcombGame {
title: string
description: string
photo: m.TcombPhotoSize[],
text?: string
text_entities?: TcombMessageEntity[],
animation?: m.TcombAnimation
}
export const Message = t.declare<TcombMessage>('Message')
Message.define(t.struct({
示例3:
import * as t from 'tcomb'
import { TcombCallbackGame, CallbackGame } from './types'
export const KeyboardButton = t.struct<TcombKeyboardButton>({
text: t.String,
request_contact: t.maybe(t.Boolean),
request_location: t.maybe(t.Boolean)
})
export interface TcombKeyboardButton {
text: string
request_contact?: boolean
request_location?: boolean
}
export const ReplyKeyboardMarkup = t.struct<TcombReplyKeyboardMarkup>({
keyboard: t.list(t.list(KeyboardButton)),
resize_keyboard: t.maybe(t.Boolean),
one_time_keyboard: t.maybe(t.Boolean),
selective: t.maybe(t.Boolean)
})
export interface TcombReplyKeyboardMarkup {
keyboard: TcombKeyboardButton[][]
resize_keyboard?: boolean
one_time_keyboard?: boolean
selective?: boolean
}
export const ReplyKeyboardRemove = t.struct<TcombReplyKeyboardRemove>({
hide_keyboard: t.Boolean,
selective: t.maybe(t.Boolean)
})
示例4:
export const Venue = t.struct<TcombVenue>({
location: Location,
title: t.String,
address: t.String,
foursquare_id: t.maybe(t.String)
})
export interface TcombVenue {
location: TcombLocation
title: string
address: string
foursquare_id?: string
}
export const UserProfilePhotos = t.struct<TcombUserProfilePhotos>({
total_count: t.Number,
photos: t.list(t.list(PhotoSize))
})
export interface TcombUserProfilePhotos {
total_count: number
photos: TcombPhotoSize[][]
}
export const File = t.struct<TcombFile>({
file_id: t.String,
file_size: t.maybe(t.Number),
file_path: t.maybe(t.String)
})
export interface TcombFile {
file_id: string
file_size?: number
file_path?: string