• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tcomb.maybe函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中tcomb.maybe函数的典型用法代码示例。如果您正苦于以下问题:TypeScript maybe函数的具体用法?TypeScript maybe怎么用?TypeScript maybe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了maybe函数的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: it

import { parse as _parse, stringify as _stringify } from '../src/parser';
import * as t from 'tcomb';

type S = {
  view: string;
  numb: number;
  bool: boolean;
  optNumb?: number;
  optBool?: boolean;
};
const ST = t.interface<S>({
  view: t.String,
  numb: t.Number,
  bool: t.Boolean,
  optNumb: t.maybe(t.Number),
  optBool: t.maybe(t.Boolean)
});
const parse = _parse(ST);
const stringify = _stringify(ST);

describe('parse', () => {
  it('should parse numbers', () => {
    expect(parse({ view: 'foo', numb: '4' })).toMatchSnapshot();
  });
  it('should parse optional numbers', () => {
    expect(parse({ view: 'foo', optNumb: '4' })).toMatchSnapshot();
  });
  it('should parse booleans', () => {
    expect(parse({ view: 'foo', bool: 'true' })).toMatchSnapshot();
  });
  it('should parse optional booleans', () => {
开发者ID:buildo,项目名称:state,代码行数:31,代码来源:parser.test.ts


示例4:

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


示例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.maybe函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tcomb.struct函数代码示例发布时间:2022-05-25
下一篇:
TypeScript tcomb.list函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap