How to use the ts-interface-checker.union function in ts-interface-checker

To help you get started, we’ve selected a few ts-interface-checker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gristlabs / ts-interface-builder / test / fixtures / sample-ti.ts View on Github external
// tslint:disable:object-literal-key-quotes

export const ICacheItem = t.iface([], {
  "key": "string",
  "value": "any",
  "size": "number",
  "tag": t.opt("string"),
});

export const ILRUCache = t.iface([], {
  "capacity": "number",
  "set": t.func("boolean", t.param("item", "ICacheItem"), t.param("overwrite", "boolean", true)),
  "get": t.func("ICacheItem", t.param("key", "string")),
});

export const MyType = t.union("boolean", "number", "ILRUCache");

export const NumberAlias = t.name("number");

export const NumberAlias2 = t.name("NumberAlias");

export const SomeEnum = t.enumtype({
  "Foo": 0,
  "Bar": 1,
});

export const Direction = t.enumtype({
  "Up": 1,
  "Down": 2,
  "Left": 17,
  "Right": 18,
});
github gristlabs / ts-interface-builder / test / fixtures / sample-ti.ts View on Github external
});

export const ISampling = t.iface(["ICacheItem"], {
  "xstring": "string",
  "xstring2": "string",
  "xany": "any",
  "xnumber": "number",
  "xnumber2": t.opt("number"),
  "xNumberAlias": "NumberAlias",
  "xNumberAlias2": "NumberAlias2",
  "xnull": "null",
  "xMyType": "MyType",
  "xarray": t.array("string"),
  "xarray2": t.array("MyType"),
  "xtuple": t.tuple("string", "number"),
  "xunion": t.union("number", "null"),
  "xparen": t.union("number", "string"),
  "xiface": t.iface([], {
    "foo": "string",
    "bar": "number",
  }),
  "xliteral": t.union(t.lit("foo"), t.lit("ba\"r"), t.lit(3)),
  "xfunc": t.func("number", t.param("price", "number"), t.param("quantity", "number")),
  "xfunc2": t.func("number", t.param("price", "number"), t.param("quantity", "number", true)),
  "xDirection": "Direction",
  "xDirectionStr": "DirectionStr",
  "xDirUp": t.union(t.enumlit("Direction", "Up"), t.enumlit("Direction", "Left")),
  "xDirStrLeft": t.enumlit("DirectionStr", "Left"),
  "ximplicit": "any",
  "ximplicitFunc": t.func("number", t.param("price", "any")),
  "ximplicitFunc2": t.func("any", t.param("price", "any")),
});
github gristlabs / ts-interface-builder / test / fixtures / sample-ti.ts View on Github external
export const ISampling = t.iface(["ICacheItem"], {
  "xstring": "string",
  "xstring2": "string",
  "xany": "any",
  "xnumber": "number",
  "xnumber2": t.opt("number"),
  "xNumberAlias": "NumberAlias",
  "xNumberAlias2": "NumberAlias2",
  "xnull": "null",
  "xMyType": "MyType",
  "xarray": t.array("string"),
  "xarray2": t.array("MyType"),
  "xtuple": t.tuple("string", "number"),
  "xunion": t.union("number", "null"),
  "xparen": t.union("number", "string"),
  "xiface": t.iface([], {
    "foo": "string",
    "bar": "number",
  }),
  "xliteral": t.union(t.lit("foo"), t.lit("ba\"r"), t.lit(3)),
  "xfunc": t.func("number", t.param("price", "number"), t.param("quantity", "number")),
  "xfunc2": t.func("number", t.param("price", "number"), t.param("quantity", "number", true)),
  "xDirection": "Direction",
  "xDirectionStr": "DirectionStr",
  "xDirUp": t.union(t.enumlit("Direction", "Up"), t.enumlit("Direction", "Left")),
  "xDirStrLeft": t.enumlit("DirectionStr", "Left"),
  "ximplicit": "any",
  "ximplicitFunc": t.func("number", t.param("price", "any")),
  "ximplicitFunc2": t.func("any", t.param("price", "any")),
});
github nomiclabs / buidler / packages / buidler-ganache / src / ganache-options-ti.ts View on Github external
/**
 * This module was automatically generated by `ts-interface-builder`
 */
import * as t from "ts-interface-checker";

export const GanacheOptionsTi = t.iface([], {
  url: "string",
  keepAliveTimeout: t.opt("number"),
  accountKeysPath: t.opt("string"),
  accounts: t.opt(t.array("object")),
  allowUnlimitedContractSize: t.opt("boolean"),
  blockTime: t.opt("number"),
  dbPath: t.opt("string"),
  debug: t.opt("boolean"),
  defaultBalanceEther: t.opt("number"),
  fork: t.opt(t.union("string", "object")),
  forkBlockNumber: t.opt(t.union("string", "number")),
  gasLimit: t.opt("number"),
  gasPrice: t.opt(t.union("string", "number")),
  hardfork: t.opt(
    t.union(t.lit("byzantium"), t.lit("constantinople"), t.lit("petersburg"))
  ),
  hdPath: t.opt("string"),
  hostname: t.opt("string"),
  locked: t.opt("boolean"),
  logger: t.opt(
    t.iface([], {
      log: t.func("void", t.param("msg", "string"))
    })
  ),
  mnemonic: t.opt("string"),
  network_id: t.opt("number"),
github nomiclabs / buidler / packages / buidler-ganache / src / ganache-options-ti.ts View on Github external
import * as t from "ts-interface-checker";

export const GanacheOptionsTi = t.iface([], {
  url: "string",
  keepAliveTimeout: t.opt("number"),
  accountKeysPath: t.opt("string"),
  accounts: t.opt(t.array("object")),
  allowUnlimitedContractSize: t.opt("boolean"),
  blockTime: t.opt("number"),
  dbPath: t.opt("string"),
  debug: t.opt("boolean"),
  defaultBalanceEther: t.opt("number"),
  fork: t.opt(t.union("string", "object")),
  forkBlockNumber: t.opt(t.union("string", "number")),
  gasLimit: t.opt("number"),
  gasPrice: t.opt(t.union("string", "number")),
  hardfork: t.opt(
    t.union(t.lit("byzantium"), t.lit("constantinople"), t.lit("petersburg"))
  ),
  hdPath: t.opt("string"),
  hostname: t.opt("string"),
  locked: t.opt("boolean"),
  logger: t.opt(
    t.iface([], {
      log: t.func("void", t.param("msg", "string"))
    })
  ),
  mnemonic: t.opt("string"),
  network_id: t.opt("number"),
  networkId: t.opt("number"),
  port: t.opt("number"),
  seed: t.opt("any"),