Skip to content

Commit

Permalink
feat: aegir types generation (#7)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wemeetagain authored Dec 18, 2020
1 parent 725cee1 commit 0fa0604
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
*
* @param {Array<ArrayLike<number>>} arrays
* @param {Number} length
* @param {Number} [length]
* @returns {Uint8Array}
*/
function concat (arrays, length) {
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"author": "Alex Potsides <alex@achingbrain.net>",
"homepage": "https://github.com/achingbrain/uint8arrays",
"bugs": "https://github.com/achingbrain/uint8arrays/issues",
"types": "dist/src/index.d.ts",
"typesVersions": {
"*": { "*": ["dist/*", "dist/*/index"] }
},
"files": [
"compare.js",
"concat.js",
Expand All @@ -28,15 +32,15 @@
"release": "aegir release --docs",
"release-minor": "aegir release --type minor --docs",
"release-major": "aegir release --type major --docs",
"build": "aegir build"
"build": "aegir build && aegir ts"
},
"license": "MIT",
"dependencies": {
"multibase": "^3.0.0",
"web-encoding": "^1.0.2"
"web-encoding": "^1.0.5"
},
"devDependencies": {
"aegir": "^25.0.0"
"aegir": "^29.2.0"
},
"contributors": [
"achingbrain <alex@achingbrain.net>"
Expand Down
2 changes: 1 addition & 1 deletion test/from-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { TextEncoder } = require('web-encoding')
describe('Uint8Array fromString', () => {
it('creates a Uint8Array from a string', () => {
const str = 'hello world'
const arr = new TextEncoder('utf8').encode(str)
const arr = new TextEncoder().encode(str)

expect(fromString(str)).to.deep.equal(arr)
})
Expand Down
2 changes: 1 addition & 1 deletion test/to-string.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { TextEncoder } = require('web-encoding')
describe('Uint8Array toString', () => {
it('creates a String from a Uint8Array', () => {
const str = 'hello world'
const arr = new TextEncoder('utf8').encode(str)
const arr = new TextEncoder().encode(str)

expect(toString(arr)).to.deep.equal(str)
})
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"test", // remove this line if you don't want to type-check tests
"."
]
}

0 comments on commit 0fa0604

Please sign in to comment.