Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to typescript #1567

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ test/auth/*

/chai.js
/chai.cjs
/lib
1 change: 0 additions & 1 deletion index.js

This file was deleted.

164 changes: 0 additions & 164 deletions lib/chai/assertion.js

This file was deleted.

55 changes: 0 additions & 55 deletions lib/chai/interface/expect.js

This file was deleted.

33 changes: 0 additions & 33 deletions lib/chai/utils/flag.js

This file was deleted.

38 changes: 37 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"name": "chai",
"type": "module",
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
"files": [
"lib",
"/chai.js",
"/register-*"
],
"keywords": [
"test",
"assertion",
Expand All @@ -29,14 +34,15 @@
"main": "./chai.js",
"scripts": {
"prebuild": "npm run clean",
"build": "npm run build:esm",
"build:esm": "esbuild --bundle --format=esm --keep-names --outfile=chai.js index.js",
"build": "npm run build:ts && npm run build:esm",
Copy link
Member

Choose a reason for hiding this comment

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

Why are we doing both? Is it to check for type errors? If yes, can we create a "lint:types": "tsc --noEmit" task and run that in the existing lint task?

"build:ts": "tsc",
"build:esm": "esbuild --bundle --format=esm --keep-names --outfile=chai.js src/chai.ts",
"pretest": "npm run lint && npm run build",
"test": "npm run test-node && npm run test-chrome",
"test-node": "mocha --require ./test/bootstrap/index.js --reporter dot test/*.js",
"test-chrome": "web-test-runner --playwright",
"lint": "eslint lib/",
"clean": "rm -f chai.js coverage"
"clean": "rm -rf chai.js coverage lib"
},
"engines": {
"node": ">=12"
Expand All @@ -46,7 +52,10 @@
"check-error": "^2.1.1",
"deep-eql": "^5.0.1",
"loupe": "^3.1.0",
"pathval": "^2.0.0"
"pathval": "^2.0.0",
"@types/check-error": "^1.0.3",
"@types/deep-eql": "^4.0.2",
"@types/pathval": "^1.1.2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you're curious: these are prod dependencies since we export some of them in our public interface. so typescript consumers need to pull these types down too

},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
Expand All @@ -56,6 +65,7 @@
"esbuild": "^0.19.10",
"eslint": "^8.56.0",
"eslint-plugin-jsdoc": "^48.0.4",
"mocha": "^10.2.0"
"mocha": "^10.2.0",
"typescript": "^5.3.3"
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about changing this to a tilde since TypeScript doesn't follow semver?

Suggested change
"typescript": "^5.3.3"
"typescript": "~5.3.3"

microsoft/TypeScript#14116

}
}
2 changes: 1 addition & 1 deletion register-assert.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {assert} from './index.js';
import {assert} from './lib/chai.js';

globalThis.assert = assert;
Loading