Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
fix: update type export
Browse files Browse the repository at this point in the history
Uses "types" field in package.json for type export.

Also updates all deps and standardaises type generation.
  • Loading branch information
achingbrain authored and vmx committed Mar 5, 2021
1 parent e7696f9 commit 889ac77
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 55 deletions.
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,51 @@
language: node_js
dist: bionic
cache: npm
stages:
- check
- test
- cov

branches:
only:
- master
- /^release\/.*$/

node_js:
- '10'
- 'lts/*'
- 'node'

os:
- linux
- osx
- windows

before_install:
# modules with pre-built binaries may not have deployed versions for bleeding-edge node so this lets us fall back to building from source
- npm install -g @mapbox/node-pre-gyp

script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

- stage: test
name: chrome
addons:
chrome: stable
script: npx aegir test -t browser -t webworker
script:
- npx aegir test -t browser -t webworker

- stage: test
name: firefox
addons:
firefox: latest
script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
script: npx aegir test -t browser -t webworker -- --browser firefox

notifications:
email: false
19 changes: 5 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
"description": "JavaScript Implementation of IPLD Block",
"leadMaintainer": "Volker Mische <volker.mische@gmail.com>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
"lint": "aegir lint",
"check": "tsc --noEmit --noErrorTruncation",
"build": "npm run build:js && npm run build:types",
"build:js": "aegir build",
"build:types": "tsc --emitDeclarationOnly --declarationDir dist",
"test": "aegir test",
"test:node": "aegir test --target node",
"test:browser": "aegir test --target browser",
Expand All @@ -19,7 +17,8 @@
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls",
"docs": "aegir docs",
"prepare": "npm run build:types"
"prepare": "aegir build --no-bundle",
"prepublishOnly": "aegir build"
},
"pre-push": [
"lint",
Expand All @@ -38,9 +37,8 @@
},
"homepage": "https://github.com/ipld/js-ipld-block#readme",
"devDependencies": {
"aegir": "^27.0.0",
"uint8arrays": "^1.0.0",
"typescript": "^4.0.3"
"aegir": "^31.0.4",
"uint8arrays": "^2.1.3"
},
"dependencies": {
"cids": "^1.0.0"
Expand All @@ -49,13 +47,6 @@
"node": ">=6.0.0",
"npm": ">=3.0.0"
},
"typesVersions": {
"*": {
"*": [
"dist/*"
]
}
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Volker Mische <volker.mische@gmail.com>",
Expand Down
5 changes: 5 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ const Block = require('../src')
describe('block', () => {
it('create throws', () => {
expect(
// @ts-expect-error arg type wrong
() => new Block('string')
).to.throw()

expect(
// @ts-expect-error arg type wrong
() => new Block(uint8ArrayFromString('hello'), 'cid')
).to.throw()

expect(
// @ts-expect-error arg type wrong
() => new Block('hello', new CID('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'))
).to.throw()
})
Expand All @@ -41,12 +44,14 @@ describe('block', () => {
const b = new Block(uint8ArrayFromString('hello'), new CID('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'))

expect(
// @ts-expect-error arg type wrong
() => { b.data = 'fail' }
).to.throw(
/read.only/
)

expect(
// @ts-expect-error arg type wrong
() => { b.cid = 'fail' }
).to.throw(
/read.only/
Expand Down
43 changes: 6 additions & 37 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,11 @@
{
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": false,
"noImplicitAny": true,
"noImplicitThis": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictFunctionTypes": false,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"strict": true,
"alwaysStrict": true,
"esModuleInterop": true,
"target": "ES2018",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"skipLibCheck": true,
"stripInternal": true,
"resolveJsonModule": true,
"paths": {
"multiformats": [
"src"
]
},
"baseUrl": "."
"outDir": "dist"
},
"include": [
"src"
],
"exclude": [
"vendor",
"node_modules"
],
"compileOnSave": false
"test",
"src",
"package.json"
]
}

0 comments on commit 889ac77

Please sign in to comment.