From bd67647b3d83697d6ac97f1c24fe1c88e91e06a9 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 24 Dec 2018 22:41:16 +0100 Subject: [PATCH 1/3] [base-x] Move v1 types to sub-dir --- types/base-x/tslint.json | 79 --------------------------- types/base-x/{ => v1}/base-x-tests.ts | 5 +- types/base-x/{ => v1}/index.d.ts | 0 types/base-x/{ => v1}/tsconfig.json | 11 +++- types/base-x/v1/tslint.json | 3 + 5 files changed, 13 insertions(+), 85 deletions(-) delete mode 100644 types/base-x/tslint.json rename types/base-x/{ => v1}/base-x-tests.ts (62%) rename types/base-x/{ => v1}/index.d.ts (100%) rename types/base-x/{ => v1}/tsconfig.json (74%) create mode 100644 types/base-x/v1/tslint.json diff --git a/types/base-x/tslint.json b/types/base-x/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/base-x/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} diff --git a/types/base-x/base-x-tests.ts b/types/base-x/v1/base-x-tests.ts similarity index 62% rename from types/base-x/base-x-tests.ts rename to types/base-x/v1/base-x-tests.ts index 44e302d2d5..3af01f8ca0 100644 --- a/types/base-x/base-x-tests.ts +++ b/types/base-x/v1/base-x-tests.ts @@ -1,7 +1,6 @@ - import * as basex from 'base-x'; -let bs16 = basex('0123456789ABCDEF'); +const bs16 = basex('0123456789ABCDEF'); { let encoded: string; @@ -10,4 +9,4 @@ let bs16 = basex('0123456789ABCDEF'); encoded = bs16.encode({0: 255, length: 1}); } -let decoded: number[] = bs16.decode('FF'); +const decoded: number[] = bs16.decode('FF'); diff --git a/types/base-x/index.d.ts b/types/base-x/v1/index.d.ts similarity index 100% rename from types/base-x/index.d.ts rename to types/base-x/v1/index.d.ts diff --git a/types/base-x/tsconfig.json b/types/base-x/v1/tsconfig.json similarity index 74% rename from types/base-x/tsconfig.json rename to types/base-x/v1/tsconfig.json index d69790c7d6..b48e3e2932 100644 --- a/types/base-x/tsconfig.json +++ b/types/base-x/v1/tsconfig.json @@ -8,10 +8,15 @@ "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, - "baseUrl": "../", + "baseUrl": "../../", "typeRoots": [ - "../" + "../../" ], + "paths": { + "base-x": [ + "base-x/v1" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -20,4 +25,4 @@ "index.d.ts", "base-x-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/base-x/v1/tslint.json b/types/base-x/v1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/base-x/v1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 1dbd6c5c8c4396956e6dc2eee7465a97d95a9f9d Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 24 Dec 2018 22:56:38 +0100 Subject: [PATCH 2/3] [base-x] Update types to v3 --- types/base-x/base-x-tests.ts | 10 ++++++++++ types/base-x/index.d.ts | 21 +++++++++++++++++++++ types/base-x/tsconfig.json | 23 +++++++++++++++++++++++ types/base-x/tslint.json | 3 +++ types/base-x/v1/index.d.ts | 6 ++---- 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 types/base-x/base-x-tests.ts create mode 100644 types/base-x/index.d.ts create mode 100644 types/base-x/tsconfig.json create mode 100644 types/base-x/tslint.json diff --git a/types/base-x/base-x-tests.ts b/types/base-x/base-x-tests.ts new file mode 100644 index 0000000000..7f50a98e54 --- /dev/null +++ b/types/base-x/base-x-tests.ts @@ -0,0 +1,10 @@ +import * as baseX from 'base-x'; + +const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; +const bs58 = baseX(BASE58); + +const decoded = bs58.decode('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr'); +decoded; // $ExpectType Buffer +bs58.decodeUnsafe('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr'); // $ExpectType Buffer | undefined + +bs58.encode(decoded); // $ExpectType string diff --git a/types/base-x/index.d.ts b/types/base-x/index.d.ts new file mode 100644 index 0000000000..1b8fa16cee --- /dev/null +++ b/types/base-x/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for base-x 3.0 +// Project: https://github.com/cryptocoinjs/base-x +// Definitions by: Ilya Mochalov +// BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Buffer } from 'buffer'; + +export = baseX; + +declare function baseX(ALPHABET: string): baseX.BaseConverter; + +declare namespace baseX { + interface BaseConverter { + encode(buffer: Buffer): string; + decodeUnsafe(string: string): Buffer | undefined; + decode(string: string): Buffer; + } +} diff --git a/types/base-x/tsconfig.json b/types/base-x/tsconfig.json new file mode 100644 index 0000000000..6f491037d2 --- /dev/null +++ b/types/base-x/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", + "base-x-tests.ts" + ] +} diff --git a/types/base-x/tslint.json b/types/base-x/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/base-x/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/base-x/v1/index.d.ts b/types/base-x/v1/index.d.ts index bbad200ce1..379eeb8182 100644 --- a/types/base-x/v1/index.d.ts +++ b/types/base-x/v1/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for base-x v1.0.1 +// Type definitions for base-x 1.0 // Project: https://github.com/cryptocoinjs/base-x // Definitions by: Ilya Mochalov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -17,7 +17,5 @@ declare namespace BaseX { decode: (string: string) => number[]; } - interface Base { - (ALPHABET: string): BaseX.BaseConverter - } + type Base = (ALPHABET: string) => BaseConverter; } From 4f1f6c0552eece03ce983ac984c71c8f5b524aef Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 24 Dec 2018 23:16:42 +0100 Subject: [PATCH 3/3] [base-x] fix dependent package tests --- types/bs58/index.d.ts | 2 -- types/bs58/tsconfig.json | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/types/bs58/index.d.ts b/types/bs58/index.d.ts index 1539910e12..bb0ef823e6 100644 --- a/types/bs58/index.d.ts +++ b/types/bs58/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Ilya Mochalov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as BaseX from 'base-x'; declare namespace base58 { } diff --git a/types/bs58/tsconfig.json b/types/bs58/tsconfig.json index 9e0ed25701..fe7563905d 100644 --- a/types/bs58/tsconfig.json +++ b/types/bs58/tsconfig.json @@ -12,6 +12,11 @@ "typeRoots": [ "../" ], + "paths": { + "base-x": [ + "base-x/v1" + ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true @@ -20,4 +25,4 @@ "index.d.ts", "bs58-tests.ts" ] -} \ No newline at end of file +}