dsherret / ts-morph

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
https://ts-morph.com
MIT License
5.02k stars 196 forks source link

Not implemented feature for syntax kind 'ParenthesizedExpression' #1574

Closed SaikaSakura closed 2 months ago

SaikaSakura commented 2 months ago

Describe the bug

Version:23.0.0

Transform JSXText Node "Explore it" to JsxExpression not worked .

To Reproduce

"use client";
import Imagex from "@/components/Imagex";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel";
import cn from "classnames";
import Autoplay from "embla-carousel-autoplay";
import Link from "next/link";
import { useTranslation } from "react-i18next";

export default function FeatureAiComicStrips() {
  const { t } = useTranslation();

  const stripInfos = [
    {
      url: "",
      stripString:
        "",
      avatar: "",
      user: "",
      createdAt: "",
    }
  ];

  return (
    <div className=" flex flex-col max-sm:space-y-5 items-center">
      <h2 className="font-bold md:leading-[52px] leading-[32px] text-[20px] md:text-[40px] font-['Crimson_Text'] text-center">
        {t("Revolutionizing AI Comic Creation")}
      </h2>
      <h3 className="md:text-[24px] md:leading-[32px] tracking-wide md:mt-[16px] max-w-[1136px] px-[15px] text-[14px] font-['Avenir_Next'] text-brand-black text-opacity-80 text-center">
        {t("Create Your Own Comic Strips Free Online, Transform stories into")}{" "}
        <span className="text-brand">{t("captivating comic strips")}</span> {t("with\n LlamaGen.AI. Our AI-powered tool makes comic creation")}{" "}
        <span className="text-brand">{t("faster, easier, and more engaging")}</span>{t(".\n Perfect for anime fans and manga artists alike. Bring your ideas to life\n with cutting-edge AI - just a few clicks and watch your comic scenes\n come alive!\n ")}</h3>
      <Link
        href="/new/ai-comic-strips"
        target="_blank"
        className=" animate-fade-up opacity-0 text-blue-500 max-sm:mt-4 max-sm:text-[12px] md:ml-4 items-center flex flex-row space-x-2 mt-[32px]"
        style={{
          animationDelay: "0.45s",
          animationFillMode: "forwards",
        }}
      >
        <Button
          variant="secondary"
          className={cn(
            "md:h-[57px] md:w-[452px] w-[266px] h-[32px]",
            "md:text-[24px] text-[12px] md:leading-[32px] leading-[16px] font-AvenirNextMedium",
            "rounded-full border-black border-2",
            "bg-[transparent] hover:bg-[rgba(255,255,255,0.5)]"
          )}
        >
          <span className="mr-[12px]">
            {t("Create your own comic strip now!")}
          </span>
          <div className="md:w-[23px] md:h-[20px] w-[12.5px] h-[10.87px] bg-[url('/bg/arrow-right.svg')] bg-center bg-cover"></div>
        </Button>
      </Link>
      <div className="flex md:flex-row flex-col md:mt-[84px] mt-[42px] max-md:p-x-[50px] items-center justify-center">
        <Carousel
          plugins={[
            Autoplay({
              delay: 4000,
            }),
          ]}
        >
          <CarouselContent className="max-md:w-[320px]">
            {stripInfos.map(
              ({ url, avatar, stripString, user, createdAt }, idx) => (
                <CarouselItem
                  key={idx}
                  className={`mt-[10px] md:mt-0 md:basis-1/3 font-['Avenir_Next'] max-md:w-[300px] max-md:flex max-md:flex-col max-md:items-center`}
                >
                  <div className="relative lg:w-[320px] md:w-[290px] w-[270px] h-[400px] border-[2px] border-[#000] rounded-xl overflow-hidden">
                    <div
                      className="w-full h-full bg-no-repeat bg-center bg-cover hover:scale-105 transition-transform duration-500"
                    >
                      <Imagex
                        width={320}
                        height={400}
                        src={url}
                        alt="artist comics"
                        className="w-full h-full"
                      />
                    </div>
                    <div
                      className={cn(
                        "absolute bottom-0 left-0",
                        "w-full md:h-[100px] md:hover:h-[203px]",
                        "pt-[20px] px-[32px]",
                        "md:text-[20px] text-[16px]",
                        "bg-[rgba(32,35,52,.75)]",
                        "rounded-b-xl",
                        "transition-[height] duration-300 ease-out",
                        "overflow-hidden"
                      )}
                    >
                      <span
                        className={cn(
                          "block",
                          "w-full md:h-[83px] h-[70px]",
                          "text-[#FFF]",
                          "text-ellipsis overflow-hidden"
                        )}
                      >
                        {stripString}
                      </span>
                      <Link
                        href="/new/ai-comic-strips"
                        target="_blank"
                        className=" animate-fade-up opacity-0 mt-[32px]"
                        style={{
                          animationDelay: "0.45s",
                          animationFillMode: "forwards",
                        }}
                      >
                        <Button
                          variant="secondary"
                          className={cn(
                            "w-full md:h-[48px] h-[32px]",
                            "md:mt-[32px] mt-[16px] max-md:mb-[16px]",
                            "leading-[32px]",
                            "rounded-xl",
                            "bg-[rgba(255,255,255,.74)] hover:bg-[rgb(255,255,255)]"
                          )}
                        >
                          <span className="w-[95px]">
                            Explore it
                          </span>
                          <div className="w-[19px] h-[16px] bg-[url('/bg/arrow-right.svg')] bg-center bg-cover"></div>
                        </Button>
                      </Link>
                    </div>
                  </div>
                  <div className="flex mt-[7px] items-center lg:w-[320px] md:w-[290px] w-[300px]">
                    <Avatar className="mr-[9px] md:w-[40px] md:h-[40px] w-[32px] h-[32px]">
                      <AvatarImage
                        width={40}
                        height={40}
                        src={avatar}
                        alt="avatar"
                        className="md:w-[40px] md:h-[40px] w-[32px] h-[32px] rounded-full"
                      />
                      <AvatarFallback>
                        <span className="text-[#FFF]">
                          {user.charAt(0).toUpperCase()}
                        </span>
                      </AvatarFallback>
                    </Avatar>
                    <span className="md:text-[20px] text-[16px] h-[28px] leading-[28px] grow">
                      {user}
                    </span>
                    <span className="text-[14px] text-brand-gray01">
                      {createdAt}
                    </span>
                  </div>
                </CarouselItem>
              )
            )}
          </CarouselContent>
          <CarouselNext className="hidden max-md:flex" />
          <CarouselPrevious className=" hidden max-md:flex" />
        </Carousel>
      </div>
    </div>
  );
}
node.transform(({ factory }) => {
        return factory.createJsxExpression(
          undefined,
          factory.createCallExpression(
            "t",
            [],
            [factory.createStringLiteral("Explore it")]
          )
        );
      });
NotImplementedError: Not implemented feature for syntax kind 'ParenthesizedExpression'.
    at throwNotImplementedForSyntaxKindError (webpack-internal:///(rsc)/./node_modules/@ts-morph/common/dist/ts-morph-common.js:431:15)
    at Object.throwNotImplementedForNeverValueError (webpack-internal:///(rsc)/./node_modules/@ts-morph/common/dist/ts-morph-common.js:448:20)
    at getContainerChildren (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:398:30)
    at getNodes (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:277:24)
    at getNodes.next (<anonymous>)
    at Function.from (<anonymous>)
    at CommentNodeParser.getOrParseChildren (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:225:30)
    at ExtendedParser.getContainerArray (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:440:34)
    at ArrowFunction._getCompilerStatementsWithComments (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:11652:39)
    at ArrowFunction.getStatementsWithComments (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:11332:25)
    at Object.getIndexedChildren (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:11676:48)
    at insertIntoBracesOrSourceFileWithGetChildren (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:2591:32)
    at ArrowFunction._insertChildren (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:11674:20)
    at ArrowFunction.insertVariableStatements (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:11595:25)
    at ArrowFunction.insertVariableStatement (webpack-internal:///(rsc)/./node_modules/ts-morph/dist/ts-morph.js:11592:25)
    at insertTransCodeForJSXFunction (webpack-internal:///(rsc)/./src/app/api/i18n/update/route.ts:97:10)

Expected behavior

JSX node can transform successfully . Sorry for the JSX code is so long .