Improve type safety using JSDocs#2
Open
koenigstag wants to merge 11 commits into
Open
Conversation
Open
Author
Build status (
|
| File | Errors |
|---|---|
| core/states/CastState.js | 14 |
| core/states/AttackState.js | 11 |
| core/states/PickupState.js | 8 |
| core/states/IdleState.js | 8 |
| core/states/FollowState.js | 8 |
| core/clientPackets/RequestMagicSkillUse.js | 6 |
| core/Models/Player.js | 6 |
| core/Managers/EntitiesManager.js | 5 |
| core/Managers/VisibilityManager.js | 4 |
| (others) | 1–2 each |
By error kind (top):
| Code | Count | Meaning |
|---|---|---|
| TS2339 | 44 | Property does not exist on type |
| TS2345 | 11 | Argument type not assignable to parameter |
| TS2322 | 11 | Type not assignable |
| TS18048 | 7 | Value is possibly undefined |
| TS2554 | 6 | Wrong number of arguments |
| TS2533 | 5 | Object is possibly null/undefined |
| TS18047 | 4 | Value is possibly null |
Most TS2339 cases come from the core/states/* chain operating on loosely-typed entities; the null/undefined family (TS18048/18047/2533) is mostly missing guards. None of these block runtime — build is noEmit type-check only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces JSDoc type annotations across the codebase and enables JS type checking (
checkJs) via the TypeScript compiler, without converting the project to TypeScript. The goal is to catch type errors at build time while keeping plain.jsruntime.Along the way this PR also fixes several real type-level bugs uncovered by the checker and does some structural refactoring of the packet layer.
~195 files touched (+2988 / −1295), mostly mechanical JSDoc additions.
Tooling
jsconfig.jsonwithcheckJs,allowJs,module/moduleResolution: nodenext,noEmit.buildscript:tsc --project jsconfig.json(type-check only, no emit).typescript,@types/node.What changed
core/: Models, Managers, states, Handlers, Systems, Events, and both client and server packet layers are annotated with@param/@returns/@typeand shared@typedefs.InitialParametersManager:updateParamsrefactored.datapack/ai/: NPC AI scripts annotated.New files
jsconfig.json— type-check configuration.enums/classIdsEnum.js— class-name → classId map.database/sql/init_db.sql— schema bootstrap for local testing (gameservers,object_id_registry,scheduled_tasks,characters,items,skills).Notes