Skip to content

Commit 0fa0604

Browse files
authored
feat: aegir types generation (#7)
Minimal updates to add autogenerated typescript types via aegir. Used this doc to help: https://github.com/ipfs/aegir/blob/master/md/ts-jsdoc.md I tested this PR locally, linking this to a test project (including updated `web-encoding` dependency) to make sure the types all line up. See #4 (comment) Resolves #3
1 parent 725cee1 commit 0fa0604

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

concat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
55
*
66
* @param {Array<ArrayLike<number>>} arrays
7-
* @param {Number} length
7+
* @param {Number} [length]
88
* @returns {Uint8Array}
99
*/
1010
function concat (arrays, length) {

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"author": "Alex Potsides <[email protected]>",
77
"homepage": "https://github.com/achingbrain/uint8arrays",
88
"bugs": "https://github.com/achingbrain/uint8arrays/issues",
9+
"types": "dist/src/index.d.ts",
10+
"typesVersions": {
11+
"*": { "*": ["dist/*", "dist/*/index"] }
12+
},
913
"files": [
1014
"compare.js",
1115
"concat.js",
@@ -28,15 +32,15 @@
2832
"release": "aegir release --docs",
2933
"release-minor": "aegir release --type minor --docs",
3034
"release-major": "aegir release --type major --docs",
31-
"build": "aegir build"
35+
"build": "aegir build && aegir ts"
3236
},
3337
"license": "MIT",
3438
"dependencies": {
3539
"multibase": "^3.0.0",
36-
"web-encoding": "^1.0.2"
40+
"web-encoding": "^1.0.5"
3741
},
3842
"devDependencies": {
39-
"aegir": "^25.0.0"
43+
"aegir": "^29.2.0"
4044
},
4145
"contributors": [
4246
"achingbrain <[email protected]>"

test/from-string.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { TextEncoder } = require('web-encoding')
88
describe('Uint8Array fromString', () => {
99
it('creates a Uint8Array from a string', () => {
1010
const str = 'hello world'
11-
const arr = new TextEncoder('utf8').encode(str)
11+
const arr = new TextEncoder().encode(str)
1212

1313
expect(fromString(str)).to.deep.equal(arr)
1414
})

test/to-string.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { TextEncoder } = require('web-encoding')
88
describe('Uint8Array toString', () => {
99
it('creates a String from a Uint8Array', () => {
1010
const str = 'hello world'
11-
const arr = new TextEncoder('utf8').encode(str)
11+
const arr = new TextEncoder().encode(str)
1212

1313
expect(toString(arr)).to.deep.equal(str)
1414
})

tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
3+
"compilerOptions": {
4+
"outDir": "dist"
5+
},
6+
"include": [
7+
"test", // remove this line if you don't want to type-check tests
8+
"."
9+
]
10+
}

0 commit comments

Comments
 (0)