Skip to content

Commit 7b36f00

Browse files
committed
try to fix typecheck
1 parent 6023831 commit 7b36f00

File tree

5 files changed

+62
-92
lines changed

5 files changed

+62
-92
lines changed

.github/workflows/typecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- name: Typecheck
2727
uses: gozala/[email protected]
2828
with:
29-
project: test/tsconfig.json
29+
project: tsconfig.json

test/tsconfig.json

Lines changed: 0 additions & 49 deletions
This file was deleted.

tsconfig.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,30 @@
2626
"resolveJsonModule": true,
2727
"emitDeclarationOnly": true,
2828
"baseUrl": ".",
29-
"composite": true
29+
"composite": true,
30+
"paths": {
31+
"multiformats": [
32+
"./src/index.js"
33+
],
34+
"multiformats/interface": [
35+
"./src/interface"
36+
],
37+
"multiformats/hashes/interface": [
38+
"./src/hashes/interface"
39+
],
40+
"multiformats/*": [
41+
"./src/*.js"
42+
],
43+
44+
}
3045
},
3146
"include": [
32-
"src"
47+
"src",
48+
"test"
3349
],
3450
"exclude": [
3551
"vendor",
52+
"test/ts-use",
3653
"node_modules"
3754
],
3855
"compileOnSave": false

vendor/base-x.d.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
declare function base(ALPHABET: string, name: string): base.BaseConverter;
2-
export = base;
3-
declare namespace base {
4-
interface BaseConverter {
5-
encode(buffer: Uint8Array | number[]): string;
6-
decodeUnsafe(string: string): Uint8Array | undefined;
7-
decode(string: string): Uint8Array;
8-
}
1+
2+
export interface BaseConverter {
3+
encode(buffer: Uint8Array | number[]): string;
4+
decodeUnsafe(string: string): Uint8Array | undefined;
5+
decode(string: string): Uint8Array;
96
}
7+
8+
export default function base(ALPHABET: string, name: string): BaseConverter

vendor/varint.d.ts

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,47 @@
33
// Definitions by: David Brockman Smoliansky <https://github.com/dbrockman>
44
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
55

6-
/// <reference types="node"/>
6+
interface Varint {
7+
encode: {
8+
/**
9+
* Encodes `num` into `buffer` starting at `offset`. returns `buffer`, with the encoded varint written into it.
10+
* `varint.encode.bytes` will now be set to the number of bytes modified.
11+
*/
12+
(num: number, buffer: Uint8Array, offset?: number): Buffer;
713

8-
export const encode: {
9-
/**
10-
* Encodes `num` into `buffer` starting at `offset`. returns `buffer`, with the encoded varint written into it.
11-
* `varint.encode.bytes` will now be set to the number of bytes modified.
12-
*/
13-
(num: number, buffer: Uint8Array, offset?: number): Buffer;
14+
/**
15+
* Encodes `num` into `array` starting at `offset`. returns `array`, with the encoded varint written into it.
16+
* If `array` is not provided, it will default to a new array.
17+
* `varint.encode.bytes` will now be set to the number of bytes modified.
18+
*/
19+
(num: number, array?: number[], offset?: number): number[]
1420

15-
/**
16-
* Encodes `num` into `array` starting at `offset`. returns `array`, with the encoded varint written into it.
17-
* If `array` is not provided, it will default to a new array.
18-
* `varint.encode.bytes` will now be set to the number of bytes modified.
19-
*/
20-
(num: number, array?: number[], offset?: number): number[]
21+
/**
22+
* Similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array).
23+
* You can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode.
24+
*/
25+
bytes: number
26+
},
2127

22-
/**
23-
* Similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array).
24-
* You can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode.
25-
*/
26-
bytes: number
27-
}
28+
decode: {
29+
/**
30+
* Decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer.
31+
* Throws a `RangeError` when `data` does not represent a valid encoding.
32+
*/
33+
(buf: Uint8Array | number[], offset?: number): number
2834

29-
export const decode: {
30-
/**
31-
* Decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer.
32-
* Throws a `RangeError` when `data` does not represent a valid encoding.
33-
*/
34-
(buf: Uint8Array | number[], offset?: number): number
35+
/**
36+
* If you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`.
37+
* This is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode.
38+
*/
39+
bytes: number
40+
},
3541

3642
/**
37-
* If you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`.
38-
* This is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode.
43+
* returns the number of bytes this number will be encoded as, up to a maximum of 8.
3944
*/
40-
bytes: number
45+
encodingLength(num: number): number
4146
}
4247

43-
/**
44-
* returns the number of bytes this number will be encoded as, up to a maximum of 8.
45-
*/
46-
export function encodingLength(num: number): number
48+
declare const varint:Varint
49+
export default varint

0 commit comments

Comments
 (0)