Skip to content

Make use of array helper functions#16226

Merged
3 commits merged into
masterfrom
array-helpers
Jun 5, 2017
Merged

Make use of array helper functions#16226
3 commits merged into
masterfrom
array-helpers

Conversation

@ghost

@ghost ghost commented Jun 2, 2017

Copy link
Copy Markdown

No description provided.

@ghost ghost requested a review from rbuckton June 2, 2017 20:40
@ghost ghost force-pushed the array-helpers branch from ef60bcb to 889daf0 Compare June 2, 2017 20:41
Comment thread src/compiler/utilities.ts
}
return result;
}
return flatMap(getJSDocs(node), doc =>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly identical to before since we now check for SyntaxKind.JSDocComment instead of SyntaxKind.JSDocParameterTag. I think it makes more sense this way though, since the cast doc as JSDoc isn't valid if all we know is that it's not an @param tag. @sandersn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tests pass then this is a good change. I tried writing it with flatMap originally but other parts of the implementation didn't work, and I forgot to change it back afterward.

I still think it's weird that the return type of mapfn is U | U[] though.

@ghost ghost merged commit 7056411 into master Jun 5, 2017
@ghost ghost deleted the array-helpers branch June 5, 2017 21:11
Comment thread src/compiler/factory.ts
if (!destEmitNode) destEmitNode = {};
if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments);
if (trailingComments) destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments);
if (leadingComments) destEmitNode.leadingComments = concatenate(leadingComments, destEmitNode.leadingComments);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I used slice was I always wanted to be sure leadingComments and trailingComments were unique arrays on an emit node, in case they are modified later. Now it is possible for someone to change the leading/trailing comments of a cloned node and it will affect the leading/trailing comments of the source node (though its not a likely scenario).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That interface is internal, but it does look like .leadingComments is potentially mutable due to addSyntheticLeadingComment.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants