Skip to content

Type expression parses breaks with nested curly braces #20

@pigulla

Description

@pigulla

It looks like the code to parse type expressions from the comments does not work properly with nested curly braces:

// test.js
/**
 * @return {{a: number, b: string}}
 */
function foo() {
    return {};
}
// .jscsrc
{
    "additionalRules": [
        "node_modules/jscs-jsdoc/lib/rules/*.js"
    ],
    "jsDoc": {
        "checkTypes": true
    }
}
// jscs --config .jscsrc test.js
Invalid JsDoc type definition at test.js :
     1 |/**
     2 | * @return {{a: number, b: string}}
-----------^
     3 | */
     4 |function foo() {


1 code style error found.

If you look at the string that gets passed to jsDocParseType you will notice that it is {a: number, b: string, so it is missing the closing curly brace.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions