#9613·engine

Broken/fragile JSDoc which happens to work through Quirks modus for /docs/

Author: kungfoomanCreated Sep 30, 2026Updated Sep 30, 2026

Currently the documentation abuses "values" for "types":

https://github.com/playcanvas/engine/blob/3c3d18a6fdca0de570047f06b0f9e35a3963ccb3/src/framework/components/joint/component.js#L615-L627

The confused IntelliSense language server can't make up the types, hovering types will display:

type MOTION_FREE = /*unresolved*/ any

The result is lack of thorough typing causing type errors along the way, duplicated sources of truth and a confused IntelliSense language experience:

Image

The solution is simple:

In constants.js:

javascript
/**
 * @typedef {typeof JOINTTYPE_FIXED | typeof JOINTTYPE_BALL | typeof JOINTTYPE_HINGE | typeof JOINTTYPE_SLIDER | typeof JOINTTYPE_6DOF} JointType
 */

/**
 * @typedef {typeof MOTION_FREE | typeof MOTION_LIMITED | typeof MOTION_LOCKED} JointMotion
 */

In joint/component.js, multiple times:

diff
- @type {MOTION_FREE|MOTION_LIMITED|MOTION_LOCKED}
+ @type {JointMotion}

Also assign proper types for the class properties and other small fixes:

javascript

/**
 * @import { Entity } from '../../entity.js'
 * @import { EventHandle } from '../../../core/event-handle.js'
 * @import { JointType, MotionType } from './constants.js'
 * @import { PhysicsJoint } from '../../physics/physics-joint.js'
 */

For class properties:

javascript
    /**
     * @type {JointType}
     * @private
     */
    _type = JOINTTYPE_FIXED;

    /**
     * @type {MotionType}
     * @private
     */
    _linearMotionX = MOTION_LOCKED;

    /**
     * @type {MotionType}
     * @private
     */
    _linearMotionY = MOTION_LOCKED;

    /**
     * @type {MotionType}
     * @private
     */
    _linearMotionZ = MOTION_LOCKED;

    /**
     * @type {MotionType}
     * @private
     */
    _angularMotionX = MOTION_LOCKED;

    /**
     * @type {MotionType}
     * @private
     */
    _angularMotionY = MOTION_LOCKED;

    /**
     * @type {MotionType}
     * @private
     */
    _angularMotionZ = MOTION_LOCKED;

    /**
     * Gets the type of joint.
     *
     * @type {JointType}
     */
    get type() {
        return this._type;
    }

I just did a test run and it fixed at least 7 type errors aswell, while improving general type safety.

/docs/ didn't settle on a decision, please discuss

Currently we have no standard how we want things to be displayed:

Image

vs:

Image

Which after an extra click resolves to:

Image

Discussion? Either decision, it's simple to make it output both styles through utils/typedoc/typedoc-plugin.mjs for all typedefs or specific ones.

Test run output for the typedefs we are talking about:

[Typedoc Plugin] Converted type 'ComponentName' -> ('button' | 'camera' | 'animation' | 'screen' | 'script' | 'model' | 'gsplat' | 'render' | 'sprite' | 'element' | 'anim' | 'audiolistener' | 'collision' | 'joint' | 'layoutchild' | 'layoutgroup' | 'light' | 'particlesystem' | 'rigidbody' | 'scrollbar' | 'scrollview' | 'sound') at [ComponentOptions.K] (Property: K)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [framework/components/joint/component.js:652] (Property: linearMotionX)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [JointComponent.linearMotionX.arg] (Property: arg)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [framework/components/joint/component.js:675] (Property: linearMotionY)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [JointComponent.linearMotionY.arg] (Property: arg)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [framework/components/joint/component.js:698] (Property: linearMotionZ)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [JointComponent.linearMotionZ.arg] (Property: arg)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [framework/components/joint/component.js:857] (Property: angularMotionX)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [JointComponent.angularMotionX.arg] (Property: arg)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [framework/components/joint/component.js:880] (Property: angularMotionY)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [JointComponent.angularMotionY.arg] (Property: arg)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [framework/components/joint/component.js:903] (Property: angularMotionZ)
[Typedoc Plugin] Converted type 'JointMotion' -> ('free' | 'limited' | 'locked') at [JointComponent.angularMotionZ.arg] (Property: arg)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:185] (Property: _coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:431] (Property: coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [Gizmo.coordSpace.value] (Property: value)
[Typedoc Plugin] Converted type 'GizmoDragMode' -> ('hide' | 'show' | 'selected') at [extras/gizmo/transform-gizmo.js:218] (Property: dragMode)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:185] (Property: _coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:431] (Property: coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [TransformGizmo.coordSpace.value] (Property: value)
[Typedoc Plugin] Converted type 'GizmoAxis' -> ('x' | 'y' | 'yz' | 'xz' | 'xy' | 'z' | 'xyz' | 'f') at [extras/gizmo/translate-gizmo.js:571] (Parameter 'activeAxis' in: _drawGuideLines())
[Typedoc Plugin] Converted type 'GizmoDragMode' -> ('hide' | 'show' | 'selected') at [extras/gizmo/transform-gizmo.js:218] (Property: dragMode)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:185] (Property: _coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:431] (Property: coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [TranslateGizmo.coordSpace.value] (Property: value)
[Typedoc Plugin] Converted type 'GizmoAxis' -> ('x' | 'y' | 'yz' | 'xz' | 'xy' | 'z' | 'xyz' | 'f') at [extras/gizmo/rotate-gizmo.js:769] (Parameter 'activeAxis' in: _drawGuideLines())
[Typedoc Plugin] Converted type 'GizmoDragMode' -> ('hide' | 'show' | 'selected') at [extras/gizmo/transform-gizmo.js:218] (Property: dragMode)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:185] (Property: _coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:431] (Property: coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [RotateGizmo.coordSpace.value] (Property: value)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/scale-gizmo.js:126] (Property: _coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/scale-gizmo.js:205] (Property: coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [ScaleGizmo.coordSpace.value] (Property: value)
[Typedoc Plugin] Converted type 'GizmoDragMode' -> ('hide' | 'show' | 'selected') at [extras/gizmo/transform-gizmo.js:218] (Property: dragMode)
[Typedoc Plugin] Converted type 'ComponentName' -> ('button' | 'camera' | 'animation' | 'screen' | 'script' | 'model' | 'gsplat' | 'render' | 'sprite' | 'element' | 'anim' | 'audiolistener' | 'collision' | 'joint' | 'layoutchild' | 'layoutgroup' | 'light' | 'particlesystem' | 'rigidbody' | 'scrollbar' | 'scrollview' | 'sound') at [MergedComponentOptions.K] (Property: K)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [extras/gizmo/gizmo.js:431] (Property: coordSpace)
[Typedoc Plugin] Converted type 'GizmoSpace' -> ('local' | 'world') at [coordSpace.value] (Property: value)
[Typedoc Plugin] Converted type 'ComponentName' -> ('button' | 'camera' | 'animation' | 'screen' | 'script' | 'model' | 'gsplat' | 'render' | 'sprite' | 'element' | 'anim' | 'audiolistener' | 'collision' | 'joint' | 'layoutchild' | 'layoutgroup' | 'light' | 'particlesystem' | 'rigidbody' | 'scrollbar' | 'scrollview' | 'sound') at [ComponentOptionsOverridesOf.K] (Property: K)
[info] html generated at ./docs

Claude metric for fixing: Count errors via tsc on fixed files, they must reduce.