literalText

tcmts.cli.npm.literalText · #ss47hhzw · term · runs anywhere

import { isNoSubstitutionTemplateLiteral, isStringLiteral } from "typescript/ast";
import type { Node } from "typescript/ast";

export const literalText = (n: Node | undefined): string | undefined =>
  n && (isStringLiteral(n) || isNoSubstitutionTemplateLiteral(n)) ? n.text : undefined

used by