diff --git a/src/language-js/print/jsx.js b/src/language-js/print/jsx.js index db4a6849705b..6f91612180f4 100644 --- a/src/language-js/print/jsx.js +++ b/src/language-js/print/jsx.js @@ -25,7 +25,6 @@ const { getLast, getPreferredQuote } = require("../../common/util.js"); const { isJsxNode, rawText, - isLiteral, isCallExpression, isStringLiteral, isBinaryish, @@ -279,7 +278,7 @@ function printJsxChildren( const parts = []; path.each((childPath, i, children) => { const child = childPath.getValue(); - if (isLiteral(child)) { + if (child.type === "JSXText") { const text = rawText(child); // Contains a non-whitespace character @@ -812,7 +811,7 @@ function isEmptyJsxElement(node) { // if there is one text child and does not contain any meaningful text // we can treat the element as empty. const child = node.children[0]; - return isLiteral(child) && !isMeaningfulJsxText(child); + return child.type === "JSXText" && !isMeaningfulJsxText(child); } // Meaningful if it contains non-whitespace characters, @@ -823,7 +822,7 @@ function isEmptyJsxElement(node) { */ function isMeaningfulJsxText(node) { return ( - isLiteral(node) && + node.type === "JSXText" && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node))) ); @@ -833,7 +832,7 @@ function isMeaningfulJsxText(node) { function isJsxWhitespaceExpression(node) { return ( node.type === "JSXExpressionContainer" && - isLiteral(node.expression) && + isStringLiteral(node.expression) && node.expression.value === " " && !hasComment(node.expression) ); diff --git a/src/language-js/print/typescript.js b/src/language-js/print/typescript.js index 63e3e109b8bc..68defeffe4e3 100644 --- a/src/language-js/print/typescript.js +++ b/src/language-js/print/typescript.js @@ -15,7 +15,7 @@ const { }, } = require("../../document/index.js"); const { - isLiteral, + isStringLiteral, getTypeScriptMappedTypeModifier, shouldPrintComma, isCallExpression, @@ -449,7 +449,7 @@ function printTypescript(path, options, print) { return ["require(", print("expression"), ")"]; case "TSModuleDeclaration": { const parent = path.getParentNode(); - const isExternalModule = isLiteral(node.id); + const isExternalModule = isStringLiteral(node.id); const parentIsDeclaration = parent.type === "TSModuleDeclaration"; const bodyIsDeclaration = node.body && node.body.type === "TSModuleDeclaration";