Skip to content

JSDocTag#comment has CRLF newlines as CR #35511

@dsherret

Description

@dsherret

TypeScript Version: 3.8.0-dev.20191128

Search Terms: JSDocTag newlines comment

Code

import * as ts from "typescript";

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

const testFilePath = "/file.ts";
const testFileText = `
/**
 * @example
 * Some\n * text\r\n * with newlines.
 */
function test() {}`;

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

console.log(JSON.stringify(tags[0].comment)); // "Some\ntext\rwith newlines."

Expected behavior:

Either:

  • "Some\ntext\r\nwith newlines." <-- probably as-is?
  • "Some\ntext\nwith newlines."

Actual behavior:

Outputs: "Some\ntext\rwith newlines."

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions