Skip to content

Use JSdoc types for code linting #30158

@s-rigaud

Description

@s-rigaud

Description

I tried setting up a JS analyzer in my VsCode config to see if any bug can be easily identified in the source code. And I tried experimenting with jsconfig.json.

{
    "compilerOptions": {
        "checkJs": true,
        "lib": [] // Do not include dom ('Node' namespace conflict)
    },
    "include": [
        "src/**/*",
        "examples/**/*"
    ]
}

This is just a little experiment but I find out two points in which this type of config might be usefull:

  • It allows to elevate types from the JSdoc and see incoherences in the used types, ex:

// src\nodes\code\ScriptableNode.js::453
// type of getOutput should be a ScriptableValueNode

image

  • It allows to detect missing/broken call to functions, ex:

// src\nodes\code\ScriptableNode.js::483

image

There is a lot of false positives or missing type references but I might be handy to look at it from time to time to detect types inconsistency and possible errors.

Solution

Use this config at the end of a documentation or development cycle to analyze possible errors.

Alternatives

Stay with the current config with less visibility on the structure of types but a faster way to document and implement things without taking to much attention to possible errors.

Additional context

Just wanted to share in case it might help the core team :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions