-
Notifications
You must be signed in to change notification settings - Fork 12.8k
fix(48540): Extract to typedef from (invalid) type with comments in JS file causes assertion failure #48545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch (node.kind) { | ||
case SyntaxKind.UnionType: | ||
members = (node as UnionTypeNode).types; | ||
break; | ||
|
||
case SyntaxKind.TypeLiteral: | ||
members = (node as TypeLiteralNode).members; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this fix is too limited - we really have to remove the comments deeply from every type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I make changes to support removing comments from node's descendants, I am not sure which other types need to be removed or is there a better way to do it?
@@ -229,6 +229,8 @@ namespace ts.refactor { | |||
function doTypedefChange(changes: textChanges.ChangeTracker, file: SourceFile, name: string, info: ExtractInfo) { | |||
const { firstStatement, selection, typeParameters } = info; | |||
|
|||
removeCommentsFromTypeNode(selection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would setting EmitFlags.NoComments | EmitFlags.NoNestedComments
work instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is definitely better 👍
Feedback should be addressed.
Fixes #48540