Skip to content

Commit

Permalink
feat: generate TypeScript declarations from source
Browse files Browse the repository at this point in the history
Closes #167
  • Loading branch information
kenany committed Mar 26, 2023
1 parent ef22831 commit c98b168
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
npm-debug.log
*.d.ts
20 changes: 0 additions & 20 deletions index.d.ts

This file was deleted.

10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ function unscale(mup, phip, options) {
}

/**
* @param {number} rating
* @param {number} rd
* @param {number} sigma
* @param {readonly Opponent[]} opponents
* @param {{ rating?: number; tau?: number; }} [options]
* @param {number} rating Rating.
* @param {number} rd Rating deviation.
* @param {number} sigma Rating volatility.
* @param {readonly Opponent[]} opponents Opponents.
* @param {{ rating?: number; tau?: number; }} [options] Options.
* @returns {{ rating: number; rd: number; vol: number; }}
*/
function rate(rating, rd, sigma, opponents, options) {
Expand Down
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,33 @@
"license": "MIT",
"author": "Kenan Yildirim <kenan@kenany.me> (https://kenany.me/)",
"main": "index.js",
"type": "index.d.ts",
"types": "index.d.ts",
"engines": {
"node": "14 || 16 || >=18"
},
"files": [
"CHANGELOG.md",
"index.d.ts",
"index.js",
"LICENSE.txt"
],
"directories": {
"test": "test"
},
"scripts": {
"clean": "rimraf --glob test/**/*.d.ts *.d.ts",
"lint": "eslint .",
"release": "semantic-release",
"type-check": "tsc",
"type-coverage": "type-coverage --at-least 100 --detail --strict",
"pretest": "npm run -s type-check && npm run -s type-coverage",

"prebuild": "npm run clean",
"build": "tsc",

"pretest": "npm run build",
"test": "tape test/index.js",
"posttest": "npm run -s lint",
"lint": "eslint index.js test/index.js bench/index.js"
"posttest": "npm run lint && npm run type-coverage",

"prepack": "npm run build"
},
"dependencies": {},
"devDependencies": {
Expand All @@ -46,6 +53,7 @@
"eslint": "^8.36.0",
"glicko2": "^1.1.0",
"lodash.isfunction": "^3.0.9",
"rimraf": "^4.4.1",
"semantic-release": "^20.1.3",
"tape": "^5.6.3",
"type-coverage": "^2.25.0",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["*.js", "test/**/*.js"]
}

0 comments on commit c98b168

Please sign in to comment.