本文整理汇总了TypeScript中vs/base/common/types.validateConstraints函数的典型用法代码示例。如果您正苦于以下问题:TypeScript validateConstraints函数的具体用法?TypeScript validateConstraints怎么用?TypeScript validateConstraints使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了validateConstraints函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('validateConstraints', () => {
types.validateConstraints([1, 'test', true], [Number, String, Boolean]);
types.validateConstraints([1, 'test', true], ['number', 'string', 'boolean']);
types.validateConstraints([console.log], [Function]);
types.validateConstraints([undefined], [types.isUndefined]);
types.validateConstraints([1], [types.isNumber]);
function foo() { }
types.validateConstraints([new foo()], [foo]);
function isFoo(f) { }
assert.throws(() => types.validateConstraints([new foo()], [isFoo]));
function isFoo2(f) { return true; }
types.validateConstraints([new foo()], [isFoo2]);
assert.throws(() => types.validateConstraints([1, true], [types.isNumber, types.isString]));
assert.throws(() => types.validateConstraints(['2'], [types.isNumber]));
assert.throws(() => types.validateConstraints([1, 'test', true], [Number, String, Number]));
});
示例2:
assert.throws(() => types.validateConstraints([1, 'test', true], [Number, String, Number]));
示例3: foo
assert.throws(() => types.validateConstraints([new foo()], [isFoo]));