fix(48540): Extract to typedef from (invalid) type with comments in JS file causes assertion failure (#48545)

* fix(48540): Remove comments from jsdoc union type expression

* fix(48540) - Remove comment for top level import and add extract typedef tests

* fix(48540) - Remove comments from jsdoc's descendant

* fix(48540) - Using no nested comments instead of traversing
This commit is contained in:
Minh Quy
2022-04-06 01:51:32 +02:00
committed by GitHub
parent 42032df06d
commit 50a5bc839a
5 changed files with 92 additions and 0 deletions

View File

@@ -229,6 +229,8 @@ namespace ts.refactor {
function doTypedefChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, info: ExtractInfo) {
const { firstStatement, selection, typeParameters } = info;
setEmitFlags(selection, EmitFlags.NoComments | EmitFlags.NoNestedComments);
const node = factory.createJSDocTypedefTag(
factory.createIdentifier("typedef"),
factory.createJSDocTypeExpression(selection),