当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript io-ts.partial函数代码示例

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


在下文中一共展示了partial函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

  metricAlias: runtimeTypes.string,
  logAlias: runtimeTypes.string,
  fields: runtimeTypes.type({
    container: runtimeTypes.string,
    host: runtimeTypes.string,
    pod: runtimeTypes.string,
    tiebreaker: runtimeTypes.string,
    timestamp: runtimeTypes.string,
  }),
});

export interface InfraSourceConfiguration
  extends runtimeTypes.TypeOf<typeof InfraSourceConfigurationRuntimeType> {}

export const PartialInfraSourceConfigurationRuntimeType = runtimeTypes.partial({
  ...InfraSourceConfigurationRuntimeType.props,
  fields: runtimeTypes.partial(InfraSourceConfigurationRuntimeType.props.fields.props),
});

export interface PartialInfraSourceConfiguration
  extends runtimeTypes.TypeOf<typeof PartialInfraSourceConfigurationRuntimeType> {}

export const InfraSavedSourceConfigurationRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    id: runtimeTypes.string,
    attributes: PartialInfraSourceConfigurationRuntimeType,
  }),
  runtimeTypes.partial({
    version: runtimeTypes.string,
    updated_at: TimestampFromString,
  }),
]);
开发者ID:lucabelluccini,项目名称:kibana,代码行数:32,代码来源:types.ts

示例2:

import * as t from "io-ts";
import * as Knex from "knex";
import * as _ from "lodash";
import Augur from "augur.js";
import { Address, MarketsRowWithTime, Payout, UIStakeInfo, PayoutRow, StakeDetails, ReportingState } from "../../types";
import { getMarketsWithReportingState, normalizePayouts, uiStakeInfoToFixed, groupByAndSum } from "./database";
import { BigNumber } from "bignumber.js";
import { QueryBuilder } from "knex";
import { ZERO } from "../../constants";

export const DisputeInfoParams = t.intersection([
  t.type({
    marketIds: t.array(t.string),
  }),
  t.partial({account: t.string}),
]);

interface DisputeRound {
  marketId: Address;
  disputeRound: number;
}

interface DisputesResult {
  markets: Array<MarketsRowWithTime>;
  stakesCompleted: Array<StakeRow>;
  stakesCurrent: Array<ActiveCrowdsourcer>;
  accountStakesCompleted: Array<StakeRow>;
  accountStakesCurrent: Array<StakeRow>;
  payouts: Array<PayoutRow<BigNumber>>;
  disputeRound: Array<DisputeRound>;
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-dispute-info.ts

示例3:

}

export const OutcomeParam = t.keyof({
  0: null,
  1: null,
  2: null,
  3: null,
  4: null,
  5: null,
  6: null,
  7: null,
});

export const SortLimitParams = t.partial({
  sortBy: t.union([t.string, t.null, t.undefined]),
  isSortDescending: t.union([t.boolean, t.null, t.undefined]),
  limit: t.union([t.number, t.null, t.undefined]),
  offset: t.union([t.number, t.null, t.undefined]),
});

export interface SortLimit {
  sortBy: string|null|undefined;
  isSortDescending: boolean|null|undefined;
  limit: number|null|undefined;
  offset: number|null|undefined;
}

export interface GetMarketInfoRequest {
  jsonrpc: string;
  id: string|number;
  method: string;
  params: {
开发者ID:AugurProject,项目名称:augur_node,代码行数:32,代码来源:types.ts

示例4:

// tslint:disable-next-line no-empty-interface
export interface CreateGameRequest extends t.TypeOf<typeof CreateGameRequestType> {}

const PositionType = t.exact(t.type({
  row: t.string,
  col: t.string,
}))

export const MoveRequestType = t.exact(t.intersection([
  t.type({
    from: PositionType,
    dest: PositionType,
  }),
  t.partial({
    promotionType: t.string,
  }),
]))

// tslint:disable-next-line no-empty-interface
export interface MoveRequest extends t.TypeOf<typeof MoveRequestType> {}

export interface ApiUser {
  id: string
  name: string
  email: string
}

export interface ApiGameInfo {
  id: string
  title: string
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:30,代码来源:types.ts

示例5:

import { Percent, safePercent, Tokens } from "../../utils/dimension-quantity";
import { getRealizedProfitPercent, getTotalProfitPercent, getUnrealizedProfitPercent } from "../../utils/financial-math";
import { getAllOutcomesProfitLoss, ProfitLossResult } from "./get-profit-loss";

export const UserTradingPositionsParamsSpecific = t.type({
  universe: t.union([t.string, t.null, t.undefined]),
  marketId: t.union([t.string, t.null, t.undefined]),
  account: t.union([t.string, t.null, t.undefined]),
  outcome: t.union([OutcomeParam, t.number, t.null, t.undefined]),
});

export const UserTradingPositionsParams = t.intersection([
  UserTradingPositionsParamsSpecific,
  SortLimitParams,
  t.partial({
    endTime: t.number,
  }),
]);

// TradingPosition represents a user's current or historical
// trading activity in one market outcome. See NetPosition.
export interface TradingPosition extends ProfitLossResult, FrozenFunds {
  position: string;
}

// AggregatedTradingPosition is an aggregation of TradingPosition for some
// scope, eg. an aggregation of all TradingPosition in a user's portfolio.
export interface AggregatedTradingPosition extends Pick<ProfitLossResult,
  "realized" | "unrealized" | "total" | "unrealizedCost" | "realizedCost" | "totalCost" | "realizedPercent" |
  "unrealizedPercent" | "totalPercent" | "unrealizedRevenue" | "unrealizedRevenue24hAgo" | "unrealizedRevenue24hChangePercent"
  >, FrozenFunds { }
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-user-trading-positions.ts

示例6:

export const plugin = t.type({});

export type Plugin = t.TypeOf<typeof plugin>;

export const rc = t.partial({
  plugins: t.array(t.union([t.string, plugin])),
  dir: t.string,
  mocha: t.partial({
    requires: t.array(t.string),
    ui: t.string,
    reporter: t.string
  }),
  webpack: t.partial({
    modifier: t.Function,
    entry: t.union([
      t.string,
      t.dictionary(t.string, t.string),
      t.array(t.string)
    ]),
    output: t.type({
      path: t.string,
      filename: t.union([t.Function, t.string])
    })
  })
});

type RCBase = t.TypeOf<typeof rc>;

type WebpackBase = RCBase['webpack'];
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:29,代码来源:RC.ts

示例7: moment

      const momentValue = moment(stringInput);
      return momentValue.isValid()
        ? runtimeTypes.success(momentValue.valueOf())
        : runtimeTypes.failure(stringInput, context);
    }),
  output => new Date(output).toISOString()
);

/**
 * Stored source configuration as read from and written to saved objects
 */

const SavedSourceConfigurationFieldsRuntimeType = runtimeTypes.partial({
  container: runtimeTypes.string,
  host: runtimeTypes.string,
  pod: runtimeTypes.string,
  tiebreaker: runtimeTypes.string,
  timestamp: runtimeTypes.string,
});

export const SavedSourceConfigurationRuntimeType = runtimeTypes.partial({
  name: runtimeTypes.string,
  description: runtimeTypes.string,
  metricAlias: runtimeTypes.string,
  logAlias: runtimeTypes.string,
  fields: SavedSourceConfigurationFieldsRuntimeType,
});

export interface InfraSavedSourceConfiguration
  extends runtimeTypes.TypeOf<typeof SavedSourceConfigurationRuntimeType> {}
开发者ID:njd5475,项目名称:kibana,代码行数:30,代码来源:types.ts

示例8: useAppContext

// Typed app routing via brilliant gcanti/io-ts.
// Soon in Next.js: https://twitter.com/timneutkens/status/1109092151907045376

const AppHrefIO = t.union([
  t.type({ pathname: t.literal('/') }),
  t.type({ pathname: t.literal('/me') }),
  t.type({ pathname: t.literal('https://twitter.com/steida') }),
  t.type({
    pathname: t.literal('/web'),
    query: t.type({ id: t.string }),
  }),
  // https://github.com/gcanti/io-ts#mixing-required-and-optional-props
  t.intersection([
    t.type({ pathname: t.literal('/signin') }),
    t.partial({ query: t.type({ redirectUrl: t.string }) }),
  ]),
]);

export type AppHref = t.TypeOf<typeof AppHrefIO>;

export const useAppHref = () => {
  const { router } = useAppContext();

  // This should be memoized globally. In serverless, it means per request :-)
  const current = useMemo<AppHref | undefined>(() => {
    let maybeAppHref: AppHref | undefined;
    const routerAppHref = { pathname: router.pathname, query: router.query };
    AppHrefIO.decode(routerAppHref).fold(
      _errors => {}, // No need to report unmatched app href.
      value => {
开发者ID:este,项目名称:este,代码行数:30,代码来源:useAppHref.ts

示例9:

import * as runtimeTypes from 'io-ts';

import { unionWithNullType } from '../framework';

/*
 *  Note Types
 */
export const SavedPinnedEventRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    timelineId: runtimeTypes.string,
    eventId: runtimeTypes.string,
  }),
  runtimeTypes.partial({
    created: runtimeTypes.number,
    createdBy: runtimeTypes.string,
    updated: runtimeTypes.number,
    updatedBy: runtimeTypes.string,
  }),
]);

export interface SavedPinnedEvent extends runtimeTypes.TypeOf<typeof SavedPinnedEventRuntimeType> {}

/**
 * Note Saved object type with metadata
 */

export const PinnedEventSavedObjectRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    id: runtimeTypes.string,
    attributes: SavedPinnedEventRuntimeType,
    version: runtimeTypes.string,
开发者ID:,项目名称:,代码行数:31,代码来源:

示例10: unionWithNullType

import * as runtimeTypes from 'io-ts';

import { unionWithNullType } from '../framework';
import { NoteSavedObjectToReturnRuntimeType } from '../note/types';
import { PinnedEventToReturnSavedObjectRuntimeType } from '../pinned_event/types';

/*
 *  ColumnHeader Types
 */
const SavedColumnHeaderRuntimeType = runtimeTypes.partial({
  aggregatable: unionWithNullType(runtimeTypes.boolean),
  category: unionWithNullType(runtimeTypes.string),
  columnHeaderType: unionWithNullType(runtimeTypes.string),
  description: unionWithNullType(runtimeTypes.string),
  example: unionWithNullType(runtimeTypes.string),
  indexes: unionWithNullType(runtimeTypes.array(runtimeTypes.string)),
  id: unionWithNullType(runtimeTypes.string),
  name: unionWithNullType(runtimeTypes.string),
  placeholder: unionWithNullType(runtimeTypes.string),
  searchable: unionWithNullType(runtimeTypes.boolean),
  type: unionWithNullType(runtimeTypes.string),
});

/*
 *  DataProvider Types
 */
const SavedDataProviderQueryMatchBasicRuntimeType = runtimeTypes.partial({
  field: unionWithNullType(runtimeTypes.string),
  displayField: unionWithNullType(runtimeTypes.string),
  value: unionWithNullType(runtimeTypes.string),
  displayValue: unionWithNullType(runtimeTypes.string),
开发者ID:,项目名称:,代码行数:31,代码来源:


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