當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript tcomb.struct函數代碼示例

本文整理匯總了TypeScript中tcomb.struct函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript struct函數的具體用法?TypeScript struct怎麽用?TypeScript struct使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了struct函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

const BaseInlineQuery = function <T>(props: any, name: string = 'Unknown') {
  return t.struct<T>(
    Object.assign(
      {},
      {
        type: t.String,
        id: t.String,
        reply_markup: t.maybe(k.InlineKeyboardMarkup),
        input_message_content: t.maybe(InputMessageContent)
      },
      props),
    name)
}
開發者ID:goodmind,項目名稱:cycle-telegram,代碼行數:13,代碼來源:inline-types.ts

示例2:

import * as t from 'tcomb'
import * as m from './multimedia-types'

export const InputFile = t.Any
export interface TcombInputFile {}

export const User = t.struct<TcombUser>({
  id: t.Number,
  first_name: t.String,
  last_name: t.maybe(t.String),
  username: t.maybe(t.String)
})
export interface TcombUser {
  id: number
  first_name: string
  last_name?: string
  username?: string
}

export const ChatMember = t.struct<TcombChatMember>({
  user: User,
  status: t.enums.of([
    'creator',
    'administrator',
    'member',
    'left',
    'kicked'
  ])
})
export interface TcombChatMember {
  user: TcombUser,
開發者ID:goodmind,項目名稱:cycle-telegram,代碼行數:31,代碼來源:types.ts

示例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)
})
開發者ID:goodmind,項目名稱:cycle-telegram,代碼行數:31,代碼來源:keyboard-types.ts

示例4: expect

 expect(() => stateInit(t.struct({}))).toThrow();
開發者ID:buildo,項目名稱:state,代碼行數:1,代碼來源:index.test.ts

示例5:

import * as t from 'tcomb'

export const PhotoSize = t.struct<TcombPhotoSize>({
  file_id: t.String,
  width: t.Number,
  height: t.Number,
  file_size: t.maybe(t.Number)
})
export interface TcombPhotoSize {
  file_id: string
  width: number
  height: number
  file_size?: number
}

export const Audio = t.struct<TcombAudio>({
  file_id: t.String,
  duration: t.Number,
  performer: t.maybe(t.String),
  title: t.maybe(t.String),
  mime_type: t.maybe(t.String),
  file_size: t.maybe(t.Number)
})
export interface TcombAudio {
  file_id: string
  duration: number
  performer?: string
  title: string
  mime_type?: string
  file_size?: number
}
開發者ID:goodmind,項目名稱:cycle-telegram,代碼行數:31,代碼來源:multimedia-types.ts


注:本文中的tcomb.struct函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。