-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Copyright comments are not preserved when generating d.ts files #5472
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
return detachedCommentsInfo; | ||
} | ||
|
||
function isPinnedComments(comment: CommentRange) { |
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.
There is already an isPinnedComments
elsewhere. Also, can you rename it to isPinnedComment
?
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.
isPinnedComments
function was in emitter.ts
and I put it inside emitDetachedComments
because it is not used anywhere else.
Yes, I can rename it.
unit tests? |
export function emitDetachedComments(currentSourceFile: SourceFile, writer: EmitTextWriter, | ||
writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void, | ||
node: TextRange, newLine: string, removeComments: boolean, | ||
detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[]) { |
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 it will be better to not pass in the detachedCommentsInfo
array into the function and return currentDetachedCommentInfo
and then have a function in emitter call emitDetachedCommentsAndUpdateCommentsInfo
that calls into this function and do the following logic
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
}
else {
detachedCommentsInfo = [currentDetachedCommentInfo];
}
So that in the case of using the function in declarationEmitter.ts, we will not be doing throw away work.
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.
also please add return type. And return type and parameter type into JSDoc
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.
also please add return type. And return type and parameter type into JSDoc
I'm not sure how to do that becase I see no other @return
or @param
in utilities.ts
. Can you elaborate?
@mhegazy Yes, I added some. |
Thanks for fast iteration. Can you add one more case with similar content but with |
@yuit Sure |
lgtm. @MartyIX thanks for the PR 🍪 |
Fix copyright comments are not preserved when generating d.ts files
This is a proposed fix for #5183 ... WIP