diff --git a/types/is-typedarray/index.d.ts b/types/is-typedarray/index.d.ts new file mode 100644 index 0000000000..39f5f91368 --- /dev/null +++ b/types/is-typedarray/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for is-typedarray 1.0 +// Project: https://github.com/hughsk/is-typedarray +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// + +export = isTypedArray; + +declare function isTypedArray(candidate: any): candidate is isTypedArray.TypedArray; + +declare namespace isTypedArray { + function strict(candidate: any): candidate is TypedArray; + function loose(candidate: any): candidate is TypedArray; + + type TypedArray = + | Int8Array + | Int16Array + | Int32Array + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Float32Array + | Float64Array + | Buffer; +} diff --git a/types/is-typedarray/is-typedarray-tests.ts b/types/is-typedarray/is-typedarray-tests.ts new file mode 100644 index 0000000000..9597f23017 --- /dev/null +++ b/types/is-typedarray/is-typedarray-tests.ts @@ -0,0 +1,19 @@ +import isTypedArray = require('is-typedarray'); + +const buf: any = new Buffer(1); + +// $ExpectType any +buf; + +if (isTypedArray(buf)) { + // $ExpectType TypedArray + buf; +} +if (isTypedArray.strict(buf)) { + // $ExpectType TypedArray + buf; +} +if (isTypedArray.loose(buf)) { + // $ExpectType TypedArray + buf; +} diff --git a/types/is-typedarray/tsconfig.json b/types/is-typedarray/tsconfig.json new file mode 100644 index 0000000000..e8886f1236 --- /dev/null +++ b/types/is-typedarray/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-typedarray-tests.ts" + ] +} diff --git a/types/is-typedarray/tslint.json b/types/is-typedarray/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-typedarray/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }