TypeScript/tests/cases/fourslash/quickInfoDisplayPartsParameters.ts
Nathan Shively-Sanders 1e48cbe2c9
Fix jsdoc comment parsing initial state (#36661)
* Fix jsdoc comment parsing initial state

Jsdoc comment parsing can be invoked in two modes:

1. top-level parsing, for comments not inside a tag.
2. tag parsing, for comment that occur after the semantic parts of a
tag.

Top-level parsing skips an initial * because it assumes that it is starting
at the very beginning of a JSDoc comment. Tag parsing does not.

The two modes are distinguished by an optional second parameter named
`margin`. When `margin` is provided, it provides an initial indent used
for comment alignment.

Previously, the check for `margin` was a truthy check `if (margin)`.
This check incorrectly treats `margin=""` the same as
`margin=undefined`.

This PR changes the check to `if (margin !== undefined)`, which
correctly treats `margin=""` the same as `margin="    "`.

* Fixes for broken tests

1. Use SawAsterisk start state.
2. @template needs to skip asterisk in addition to whitespace while
parsing type parameter names.

* undo code move
2020-02-07 08:35:40 -08:00

12 lines
408 B
TypeScript

/// <reference path='fourslash.ts'/>
//// /** @return *crunch* */
//// function /*1*/foo(/*2*/param: string, /*3*/optionalParam?: string, /*4*/paramWithInitializer = "hello", .../*5*/restParam: string[]) {
//// /*6*/param = "Hello";
//// /*7*/optionalParam = "World";
//// /*8*/paramWithInitializer = "Hello";
//// /*9*/restParam[0] = "World";
//// }
verify.baselineQuickInfo();