Microsoft/TypeScript

JSDocTag width is inconsistent

Open

#35.455 geöffnet am 3. Dez. 2019

Auf GitHub ansehen
 (6 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (6.726 Forks)batch import
BugDomain: JSDocEffort: ModerateHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

TypeScript Version: 3.8.0-dev.20191128

Search Terms: JSDocTag parsing JS doc

Code

import * as ts from "typescript";

console.log(ts.version); // 3.8.0-dev.20191128

const testFilePath = "/file.ts";
const testFileText = `
/**
 * @example Some text.
 * @param someParam - Some text.
 */
function test() {}`;

const testSourceFile = ts.createSourceFile(testFilePath, testFileText, ts.ScriptTarget.Latest, true);
const funcDec = testSourceFile.statements.find(ts.isFunctionDeclaration)!;
const tags = ts.getJSDocTags(funcDec);
const firstTag = tags[0];

console.log(firstTag.getText(testSourceFile)); // "@example"
console.log(firstTag.tagName.getText(testSourceFile)); // "example"
console.log(firstTag.comment); // "Some text."
console.log(firstTag.pos); // 8
console.log(firstTag.end); // 17
console.log(firstTag.getWidth(testSourceFile)); // 9

const secondTag = tags[1];

console.log(secondTag.getText(testSourceFile)); // "@param someParam - SomeText.\n"
console.log(secondTag.tagName.getText(testSourceFile)); // "param"
console.log(secondTag.comment); // "- Some text."
console.log(secondTag.pos); // 31
console.log(secondTag.end); // 62
console.log(secondTag.getWidth(testSourceFile)); // 31

image

image

Expected behavior: The width would act the same for both.

Actual behavior: It's inconsistent or I'm missing something about JSDocParameterTag.

Contributor Guide