TypeScript/tests/cases/fourslash/quickInfoForJSDocCodefence.ts
Nathan Shively-Sanders c3a9429420
Handle JSDoc backticks in the parser, not scanner (#30939)
* Scan backticks in jsdoc as a single token less often

Previously, matching backticks in jsdoc would always be scanned as one
token to aid parsing incorrect jsdoc that uses backticks for parameter
names:

``js
/** @param {string} `nope`
 * @param {number} `not needed`
 */
```

However, this is wrong for code fences, which use triple backticks. This
fix parses a single backtick as a single token if it's immediately
followed by another backtick or by a newline. It retains the
questionable tokenisation of backticks-as-pairs in other cases, however.
A better fix might be to have the parser ignore backticks in jsdoc
instead.

* Add test case

* Handle jsdoc backticks in the parser, not scanner

Previously, the jsdoc scanner had ad-hoc handling of backticks that was
similar in structure to the normal scanner's handling, but much simpler.
This was a smaller code change, but is handled backwards: the special
case of backtick-quoted parameter names was handled in the scanner
instead of in the jsdoc identifier parsing code. That made it overapply
and block correct handling of asterisks across newlines, which was most
obvious in code fences inside jsdoc, as in #23517.

Fixes #23517

* More cleanup
2019-04-18 09:35:40 -07:00

22 lines
302 B
TypeScript

/// <reference path='fourslash.ts' />
/////**
//// * @example
//// * ```
//// * 1 + 2
//// * ```
//// */
////function fo/*1*/o() {
//// return '2';
////}
/////**
//// * @example
//// * ``
//// * 1 + 2
//// * `
//// */
////function bo/*2*/o() {
//// return '2';
////}
verify.baselineQuickInfo();