Merge pull request #31493 from BendingBender/is-typedarray

[is-typedarray] Add types
This commit is contained in:
Nathan Shively-Sanders
2018-12-17 15:23:47 -08:00
committed by GitHub
4 changed files with 71 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for is-typedarray 1.0
// Project: https://github.com/hughsk/is-typedarray
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
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;
}
@@ -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;
}
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }