added definition for type-detect

This commit is contained in:
Bart van der Schoor 2014-06-19 19:41:36 +02:00
parent 6745ac3279
commit b4eb7a76f3
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,20 @@
/// <reference path="type-detect.d.ts" />
import td = require('type-detect');
var str: string;
var bool: boolean;
var x: any;
str = td(123);
var lib: td.Library = new td.Library();
lib.define(str, /aa/);
lib.define(str, (val) => {
return bool;
});
str = lib.of(x);
bool = lib.test(x, str);

18
type-detect/type-detect.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
// Type definitions for type-detect v0.1.2
// Project: https://github.com/chaijs/type-detect
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'type-detect' {
function type(val: any): string;
module type {
export class Library {
of(val: any): string;
define (type: string, test: RegExp): void;
define (type: string, test: (val: any) => boolean): void;
test (val: any, type: string): boolean;
}
}
export = type;
}