Skip to content

[Regression] jsdoc/valid-types for postfix nullable properties #748

@kevinoid

Description

@kevinoid

Expected behavior

jsdoc/valid-types does not warn for {message: string?}.

Actual behavior

index.js:2:0: Syntax error in type: {message: string?} [Warning/jsdoc/valid-types]

ESLint Config

{
  "extends": [
    "plugin:jsdoc/recommended"
  ]
}

ESLint sample

/**
 * @param {{message: string?}} options Options.
 */
function MyError(options) {
}

Environment

  • Node version: v12.21.0
  • ESLint version v7.27.0
  • eslint-plugin-jsdoc version: v35.1.1 or v35.1.0

Additional Info

The issue does not occur with eslint-plugin-jsdoc@35.0.0 or earlier. The postfix ? to indicate a nullable type is not mentioned in https://jsdoc.app/tags-type.html. It is mentioned in https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#user-content-the-javascript-type-language as a deprecated syntax. I'm not sure whether it should be accepted without settings.jsdoc.mode: closure (it does not appear to be accepted with settings.jsdoc.mode: closure either).

Thanks,
Kevin

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions