Typescript: JSDoc Property Name with Dash Not Recognized

Created on 1 Mar 2017  路  11Comments  路  Source: microsoft/TypeScript



From https://github.com/Microsoft/vscode/issues/21592

TypeScript Version: 2.2.1

Code

/**
 * @typedef Product
 * @property {string} title
 * @property {boolean} high-top
 */

/**
 * @type {Product}
 */
const product = null

Expected behavior:
product has a high-top property.

Actual behavior:
product has a high property:

Trace - 12:00:17 PM] Sending request: completions (39). Response expected: yes. Current queue length: 0
Arguments: {
    "file": "/Users/matb/projects/sand/bar.js",
    "line": 12,
    "offset": 9
}
[Trace - 12:00:17 PM] Response received: completions (39). Request took 16 ms. Success: true 
Result: [
    {
        "name": "Product",
        "kind": "warning",
        "kindModifiers": "",
        "sortText": "1"
    },
    {
        "name": "high",
        "kind": "property",
        "kindModifiers": "",
        "sortText": "0"
    },
    {
        "name": "product",
        "kind": "warning",
        "kindModifiers": "",
        "sortText": "1"
    },
    {
        "name": "title",
        "kind": "property",
        "kindModifiers": "",
        "sortText": "0"
    }
]
Bug JSDoc VS Code Tracked good first issue help wanted

Most helpful comment

TypeScript handles this OK. However, syntax highlighting in VSCode does not.

All 11 comments

Hi, can I try this one? Would be my first PR in TS

go for it.

This issue looks like it hasn't been touched in a while, so I'd love to try it. Do you have any suggestions for where to start?

Name with dash is not a legal identifier, such property can only be accessed with o['x-x'], however I can put whatever in a string even o[' a '], so how to recognize the contents after white space trivia is property name or comment?

@fuafa maybe with a char after and before its name, similar to string values.

/**
 * ...
 * @property {boolean} "high-top"
 */

Unfortunately not yet, @VitorLuizC.

It says this is fixed but in VSCode I'm seeing:

@enjikaka It is fixed in 3.7 but not 3.6: http://www.typescriptlang.org/play/?ts=3.7-Beta&useJavaScript=true#code/PQKhCgAIUgBAXAngBwKYBNUDNIAUBOA9ugK4DG8UMsyRa+SkA3gM7z4CWAdgOYC+keB3gAbVFTi1C9RkwBGhQmICGXAQAsOPdQFp40qsHDgAHpAC8kAIxA

Aha, not out yet. I though it would be out by now as it was merged in August.

TypeScript handles this OK. However, syntax highlighting in VSCode does not.

Looks like JSDoc doesn't recognize names with dash in VSCode. Is it just me?

Was this page helpful?
0 / 5 - 0 ratings