Skip to content

Using jsdoc/no-undefined-types without actually checking if types are undefined. #793

Closed
@jespertheend

Description

@jespertheend

Motivation

I would like to use types in jsdoc without having to use import().
For instance, instead of doing

/** @type {import("../../../../some/very/long/path.js").MyStruct} */
const obj = {
    // ...
}

I would like to do

import {MyStruct} from "../../../../some/very/long/path.js";

/** @type {MyStruct} */
const obj = {
    // ...
}

However, at the moment this causes an eslint no-unused-vars error.
Afaik the only way to solve this is by enabling jsdoc/no-undefined-types, however, this causes errors when using certain types like Generator or ConstructorParameters. If #99 is added we can import the same files that are used for typescript.
But until then the only way to suppress these errors is by providing a list of types in definedTypes for jsdoc/no-undefined-types, which is not ideal.

Would there be some sort of way to use jsdoc/no-undefined-types for suppressing no-unused-vars errors only? That is, mark variables as used without actually checking if the used type is a valid type?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions