refactor: introduce typescript for static type checking

We use JSDoc for documentation, but these annotations
were not being validated. This meant that type information
could become outdated or incorrect without any warning.

This commit introduces the TypeScript compiler (`tsc`) as a static
analysis tool to leverage our existing JSDoc comments.

To support this, JSDoc annotations across the codebase have been
improved for accuracy. Additionally, the `varint` module now uses a
custom `VarIntError` class for better type inference and error handling.
A new `typecheck` script has been added to `package.json` to run this
validation.
This commit is contained in:
2025-06-19 02:57:11 +03:00
parent 7322034aba
commit a1b999ca4e
6 changed files with 168 additions and 80 deletions

View File

@ -7,7 +7,8 @@
"types": "types/index.d.ts",
"scripts": {
"test": "vitest run",
"test:watch": "vitest"
"test:watch": "vitest",
"typecheck": "tsc --noEmit"
},
"repository": {
"type": "git",
@ -27,6 +28,9 @@
"debug": "^4.4.1"
},
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/node": "^24.0.3",
"typescript": "^5.8.3",
"vitest": "^3.2.3"
}
}