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

Commit 889ac77

Browse files
achingbrainvmx
authored andcommitted
fix: update type export
Uses "types" field in package.json for type export. Also updates all deps and standardaises type generation.
1 parent e7696f9 commit 889ac77

File tree

4 files changed

+31
-55
lines changed

4 files changed

+31
-55
lines changed

.travis.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
11
language: node_js
2+
dist: bionic
23
cache: npm
34
stages:
45
- check
56
- test
67
- cov
78

9+
branches:
10+
only:
11+
- master
12+
- /^release\/.*$/
13+
814
node_js:
9-
- '10'
15+
- 'lts/*'
16+
- 'node'
1017

1118
os:
1219
- linux
1320
- osx
1421
- windows
1522

23+
before_install:
24+
# modules with pre-built binaries may not have deployed versions for bleeding-edge node so this lets us fall back to building from source
25+
- npm install -g @mapbox/node-pre-gyp
26+
1627
script: npx nyc -s npm run test:node -- --bail
1728
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
1829

1930
jobs:
2031
include:
2132
- stage: check
2233
script:
23-
- npx aegir commitlint --travis
2434
- npx aegir dep-check
2535
- npm run lint
2636

2737
- stage: test
2838
name: chrome
2939
addons:
3040
chrome: stable
31-
script: npx aegir test -t browser -t webworker
41+
script:
42+
- npx aegir test -t browser -t webworker
3243

3344
- stage: test
3445
name: firefox
3546
addons:
3647
firefox: latest
37-
script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
48+
script: npx aegir test -t browser -t webworker -- --browser firefox
3849

3950
notifications:
4051
email: false

package.json

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
"description": "JavaScript Implementation of IPLD Block",
55
"leadMaintainer": "Volker Mische <[email protected]>",
66
"main": "src/index.js",
7+
"types": "dist/src/index.d.ts",
78
"scripts": {
89
"lint": "aegir lint",
910
"check": "tsc --noEmit --noErrorTruncation",
10-
"build": "npm run build:js && npm run build:types",
11-
"build:js": "aegir build",
12-
"build:types": "tsc --emitDeclarationOnly --declarationDir dist",
1311
"test": "aegir test",
1412
"test:node": "aegir test --target node",
1513
"test:browser": "aegir test --target browser",
@@ -19,7 +17,8 @@
1917
"coverage": "aegir coverage",
2018
"coverage-publish": "aegir coverage --provider coveralls",
2119
"docs": "aegir docs",
22-
"prepare": "npm run build:types"
20+
"prepare": "aegir build --no-bundle",
21+
"prepublishOnly": "aegir build"
2322
},
2423
"pre-push": [
2524
"lint",
@@ -38,9 +37,8 @@
3837
},
3938
"homepage": "https://github.com/ipld/js-ipld-block#readme",
4039
"devDependencies": {
41-
"aegir": "^27.0.0",
42-
"uint8arrays": "^1.0.0",
43-
"typescript": "^4.0.3"
40+
"aegir": "^31.0.4",
41+
"uint8arrays": "^2.1.3"
4442
},
4543
"dependencies": {
4644
"cids": "^1.0.0"
@@ -49,13 +47,6 @@
4947
"node": ">=6.0.0",
5048
"npm": ">=3.0.0"
5149
},
52-
"typesVersions": {
53-
"*": {
54-
"*": [
55-
"dist/*"
56-
]
57-
}
58-
},
5950
"contributors": [
6051
"David Dias <[email protected]>",
6152
"Volker Mische <[email protected]>",

test/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ const Block = require('../src')
1010
describe('block', () => {
1111
it('create throws', () => {
1212
expect(
13+
// @ts-expect-error arg type wrong
1314
() => new Block('string')
1415
).to.throw()
1516

1617
expect(
18+
// @ts-expect-error arg type wrong
1719
() => new Block(uint8ArrayFromString('hello'), 'cid')
1820
).to.throw()
1921

2022
expect(
23+
// @ts-expect-error arg type wrong
2124
() => new Block('hello', new CID('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'))
2225
).to.throw()
2326
})
@@ -41,12 +44,14 @@ describe('block', () => {
4144
const b = new Block(uint8ArrayFromString('hello'), new CID('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n'))
4245

4346
expect(
47+
// @ts-expect-error arg type wrong
4448
() => { b.data = 'fail' }
4549
).to.throw(
4650
/read.only/
4751
)
4852

4953
expect(
54+
// @ts-expect-error arg type wrong
5055
() => { b.cid = 'fail' }
5156
).to.throw(
5257
/read.only/

tsconfig.json

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,11 @@
11
{
2+
"extends": "./node_modules/aegir/src/config/tsconfig.aegir.json",
23
"compilerOptions": {
3-
"allowJs": true,
4-
"checkJs": true,
5-
"forceConsistentCasingInFileNames": true,
6-
"noImplicitReturns": false,
7-
"noImplicitAny": true,
8-
"noImplicitThis": true,
9-
"noFallthroughCasesInSwitch": true,
10-
"noUnusedLocals": true,
11-
"noUnusedParameters": true,
12-
"strictFunctionTypes": false,
13-
"strictNullChecks": true,
14-
"strictPropertyInitialization": true,
15-
"strictBindCallApply": true,
16-
"strict": true,
17-
"alwaysStrict": true,
18-
"esModuleInterop": true,
19-
"target": "ES2018",
20-
"moduleResolution": "node",
21-
"declaration": true,
22-
"declarationMap": true,
23-
"outDir": "dist",
24-
"skipLibCheck": true,
25-
"stripInternal": true,
26-
"resolveJsonModule": true,
27-
"paths": {
28-
"multiformats": [
29-
"src"
30-
]
31-
},
32-
"baseUrl": "."
4+
"outDir": "dist"
335
},
346
"include": [
35-
"src"
36-
],
37-
"exclude": [
38-
"vendor",
39-
"node_modules"
40-
],
41-
"compileOnSave": false
7+
"test",
8+
"src",
9+
"package.json"
10+
]
4211
}

0 commit comments

Comments
 (0)