From 24201cfe6e7c561b7f1e23b536460f9e65d6a409 Mon Sep 17 00:00:00 2001 From: Zixiang Li Date: Wed, 21 Aug 2019 05:49:40 +0800 Subject: [PATCH] Add support for jsdoc properties with hyphen (#32631) --- src/compiler/scanner.ts | 2 +- tests/cases/fourslash/jsDocTagsWithHyphen.ts | 24 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/jsDocTagsWithHyphen.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 3f7db7d2eb3..af9f565fb52 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2182,7 +2182,7 @@ namespace ts { if (isIdentifierStart(ch, languageVersion)) { let char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) pos += charSize(char); + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === CharacterCodes.minus) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === CharacterCodes.backslash) { tokenValue += scanIdentifierParts(); diff --git a/tests/cases/fourslash/jsDocTagsWithHyphen.ts b/tests/cases/fourslash/jsDocTagsWithHyphen.ts new file mode 100644 index 00000000000..188c4298bcb --- /dev/null +++ b/tests/cases/fourslash/jsDocTagsWithHyphen.ts @@ -0,0 +1,24 @@ +/// +// @allowJs: true +// @Filename: dummy.js + +//// /** +//// * @typedef Product +//// * @property {string} title +//// * @property {boolean} h/*1*/igh-top some-comments +//// */ +//// +//// /** +//// * @type {Pro/*2*/duct} +//// */ +//// const product = { +//// /*3*/ +//// } +verify.quickInfoAt('1', '(property) high-top: boolean', 'some-comments'); + +verify.quickInfoAt('2', 'type Product = {\n title: string;\n high-top: boolean;\n}'); + +verify.completions({ + marker: ['3'], + includes: ['"high-top"'] +});