Skip to content

JSDoc type ...*? is treated incorrectly #18691

@sandersn

Description

@sandersn

I think that ...*? is equivalent to the typescript type any[] | null. However, it results in the type any[].

// @checkJs: true
// @allowJs: true
// @strict: true
/**
 * @return {...*?}
 */
function f() {
    return null // fine, but should be an error? maybe?
}

Expected behavior:

I'm not actually sure what the correct behaviour is:

  1. Parse error
  2. any[] | null
  3. (any | null)[] (but this would mean that the prefix type parsed after the suffix type, which is incorrect).

And I'm not sure whether the error is in the parser or in getTypeOfTypeNode.

Also note that ...*= doesn't parse at all, but this is less bad (I think?).

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions