Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches:
- master
- main
- default
pull_request:
branches:
- "**"

name: Typecheck
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/[email protected]
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Typecheck
uses: gozala/[email protected]
with:
project: test/tsconfig.json
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"version": "0.0.0-dev",
"description": "Interface for multihash, multicodec, multibase and CID",
"main": "./src/index.js",
"types": "./types/index.d.ts",
"types": "./types/src/index.d.ts",
"type": "module",
"scripts": {
"build": "npm run build:js && npm run build:types",
"build:js": "ipjs build --tests --main && npm run build:copy",
"build:copy": "cp -a src vendor test dist/ && rm -rf dist/test/ts-use",
"build:types": "npm run build:copy && cd dist && tsc --build src/tsconfig.json test/tsconfig.json",
"build:copy": "cp -a tsconfig.json src vendor test dist/ && rm -rf dist/test/ts-use",
"build:types": "npm run build:copy && cd dist && tsc --build",
"build:vendor": "npm run build:vendor:varint && npm run build:vendor:base-x",
"build:vendor:varint": "npm_config_yes=true npx brrp -x varint > vendor/varint.js",
"build:vendor:base-x": "npm_config_yes=true npx brrp -x @multiformats/base-x > vendor/base-x.js",
Expand All @@ -21,6 +21,7 @@
"test:esm:browser": "polendina --page --worker --serviceworker --cleanup dist/esm/browser-test/test-*.js",
"test:ts": "npm run build:types && npm run test --prefix test/ts-use",
"test": "npm run lint && npm run test:node && npm run test:esm && npm run test:ts",
"typecheck": "tsc --build test/tsconfig.json",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it get run by the gozala/typescript-error-reporter-action? If not, then I don't think this gets run by anything automatically, or manually unless someone runs it directly, is it?

Let's wire this up to one of the main scripts that devs will be using- maybe just add it in to "test", "build:types" would also work but it's not really a "build" script per se.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just mostly added for convenience so I could run npm run typecheck, it should not create build artifacts because tsconfig.json has noEmit. I wish there was tsc check but sadly TS is not exactly what some would wish for.

I can remove this

"test:ci": "npm run lint && npm run test:node && npm run test:esm && npm run test:cjs && npm run test:ts",
"coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080"
},
Expand Down Expand Up @@ -140,7 +141,7 @@
"typesVersions": {
"*": {
"*": [
"types/*"
"types/src/*"
],
"types/*": [
"types/*"
Expand Down
15 changes: 3 additions & 12 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"references": [
{
"path": "../src/"
"path": "../"
}
],
"compilerOptions": {
Expand All @@ -25,19 +25,10 @@
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"outDir": "../types",
"skipLibCheck": true,
"stripInternal": true,
"resolveJsonModule": true,
"noEmit": true,
"paths": {
"multiformats": [
"../src/index.js"
],
"multiformats/*": [
"../src/*.js"
]
}
"noEmit": true
},
"include": [
"test/",
Expand All @@ -46,4 +37,4 @@
"exclude": [
"ts-use/"
]
}
}
11 changes: 7 additions & 4 deletions src/tsconfig.json → tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"outDir": "../types",
"outDir": "types",
"skipLibCheck": true,
"stripInternal": true,
"resolveJsonModule": true,
Expand All @@ -29,8 +29,11 @@
"composite": true
},
"include": [
"."
"src"
],
"exclude": [
"vendor",
"node_modules"
],
"exclude": [],
"compileOnSave": false
}
}