Stabilize comments on ObjectTypeAnnotation (#1214)

This commit is contained in:
Brian Ng authored and Christopher Chedeau committed 2017-04-12 14:13:34 -07:00
1 parent b82220b20f
commit 32eecabc6d
3 files changed
+86

No files matched your search

+9
View File
@@ -219,6 +219,7 @@ function attach(comments, ast, text, options) {
handleExportNamedDeclarationComments(enclosingNode, comment) ||
handleOnlyComments(enclosingNode, ast, comment, isLastComment) ||
handleClassMethodComments(enclosingNode, comment) ||
handleTypeAliasComments(enclosingNode, followingNode, comment) ||
handleVariableDeclaratorComments(enclosingNode, followingNode, comment)
) {
// We're good
@@ -734,6 +735,14 @@ function handleClassMethodComments(enclosingNode, comment) {
return false;
}
function handleTypeAliasComments(enclosingNode, followingNode, comment) {
if (enclosingNode && enclosingNode.type === "TypeAlias") {
addLeadingComment(enclosingNode, comment);
return true;
}
return false;
}
function handleVariableDeclaratorComments(
enclosingNode,
followingNode,
@@ -29,3 +29,67 @@ const beep = (data /*: Object*/) => {};
const beep = (data /*: Object*/, secondData /*: Object*/) => {};
`;
exports[`object_type_annotation.js 1`] = `
type Props = // (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
{
isPlaying: boolean,
};
type Props = { // (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
type Props = {
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
`;
exports[`object_type_annotation.js 2`] = `
type Props = // (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
{
isPlaying: boolean,
};
type Props = { // (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
type Props = {
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
`;
@@ -0,0 +1,13 @@
type Props = // (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
{
isPlaying: boolean,
};
type Props = { // (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};
type Props = {
// (DispatchProps & StateProps); WHY DON'T YOU WORK FLOW!!!!!!!!!
isPlaying: boolean
};