Fix "TypeError: comments is not iterable" (#8701)
This commit is contained in:
parent
4f206b2416
commit
bf8c4785f2
@ -25,15 +25,19 @@ export default declare(api => {
|
||||
skipStrip = false;
|
||||
let directiveFound = false;
|
||||
|
||||
for (const comment of (comments: Array<Object>)) {
|
||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
||||
directiveFound = true;
|
||||
if (comments) {
|
||||
for (const comment of (comments: Array<Object>)) {
|
||||
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
|
||||
directiveFound = true;
|
||||
|
||||
// remove flow directive
|
||||
comment.value = comment.value.replace(FLOW_DIRECTIVE, "");
|
||||
// remove flow directive
|
||||
comment.value = comment.value.replace(FLOW_DIRECTIVE, "");
|
||||
|
||||
// remove the comment completely if it only consists of whitespace and/or stars
|
||||
if (!comment.value.replace(/\*/g, "").trim()) comment.ignore = true;
|
||||
// remove the comment completely if it only consists of whitespace and/or stars
|
||||
if (!comment.value.replace(/\*/g, "").trim()) {
|
||||
comment.ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -51,16 +51,18 @@ export default declare((api, options) => {
|
||||
let pragmaSet = !!options.pragma;
|
||||
let pragmaFragSet = !!options.pragmaFrag;
|
||||
|
||||
for (const comment of (file.ast.comments: Array<Object>)) {
|
||||
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxMatches) {
|
||||
pragma = jsxMatches[1];
|
||||
pragmaSet = true;
|
||||
}
|
||||
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxFragMatches) {
|
||||
pragmaFrag = jsxFragMatches[1];
|
||||
pragmaFragSet = true;
|
||||
if (file.ast.comments) {
|
||||
for (const comment of (file.ast.comments: Array<Object>)) {
|
||||
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxMatches) {
|
||||
pragma = jsxMatches[1];
|
||||
pragmaSet = true;
|
||||
}
|
||||
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (jsxFragMatches) {
|
||||
pragmaFrag = jsxFragMatches[1];
|
||||
pragmaFragSet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user