diff --git a/types/minimal-bit-array/index.d.ts b/types/minimal-bit-array/index.d.ts new file mode 100644 index 0000000000..f5172fbd47 --- /dev/null +++ b/types/minimal-bit-array/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for minimal-bit-array 1.0 +// Project: https://github.com/mikolalysenko/minimal-bit-array +// Definitions by: Olegs Jeremejevs +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace BitArray { + interface BitArrayJSON { + bits: number[]; + length: number; + } +} + +declare class BitArray { + static fromJSON(bitArrayJSON: BitArray.BitArrayJSON): BitArray; + + length: number; + bits: Uint32Array; + + constructor(length: number); + + get(index: number): boolean; + set(index: number, value: any): boolean; + toJSON(): BitArray.BitArrayJSON; +} + +export = BitArray; diff --git a/types/minimal-bit-array/minimal-bit-array-tests.ts b/types/minimal-bit-array/minimal-bit-array-tests.ts new file mode 100644 index 0000000000..135b2908f2 --- /dev/null +++ b/types/minimal-bit-array/minimal-bit-array-tests.ts @@ -0,0 +1,9 @@ +import * as BitArray from "minimal-bit-array"; + +new BitArray('abc'); // $ExpectError +const bitArray: BitArray = new BitArray(123); +bitArray.get(12); // $ExpectType boolean +bitArray.set(34, true); // $ExpectType boolean +bitArray.set(34, 'someTruthyValue'); +const json: BitArray.BitArrayJSON = bitArray.toJSON(); +const bitArrayClone: BitArray = BitArray.fromJSON(json); diff --git a/types/minimal-bit-array/tsconfig.json b/types/minimal-bit-array/tsconfig.json new file mode 100644 index 0000000000..6858a768bd --- /dev/null +++ b/types/minimal-bit-array/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "minimal-bit-array-tests.ts" + ] +} diff --git a/types/minimal-bit-array/tslint.json b/types/minimal-bit-array/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/minimal-bit-array/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }