+
Skip to content

Following query behaves weird: '$a as $b => $a' #659

@TheKnarf

Description

@TheKnarf

Versions
grit 0.1.1

Steps to reproduce

The following query behaves weirdly:

pnpm grit apply --dry-run '`$a as $b` => `$a`'

I want to use it to remove typecasts in the code.
It does correctly match a bunch of typecasts, but then it also matches a couple of weird cases:

./src/components/dialog/NewRequestDialog.tsx
     import { useTranslation } from "@/i18n/client";
     import { api } from "@/trpc/react";
     import type { ExtendedFolder } from "@/types/types";
    -import { type Folder, Priority } from "@prisma/client";
    +import { Folder, Priority } from "@prisma/client";
     import { useEffect, useState } from "react";
     import { toast } from "sonner";
     import { FoldersAccordion } from "../FoldersAccordion";
                   </>
                 )}
                 <FoldersAccordion
    -              dataRoomId={dataRoomId as string}
    +              dataRoomId={dataRoomId}
                   folders={nestedFolders[""] || []}
                   subFoldersMap={nestedFolders}
                   onClickFolderCallback={handleSelectFolder}

It correctly tries to remove the as string, but then it also removes the type from my import statement?

And then it shows me a lot of empty diffs:

./src/components/queries/@questions/replySideBar/ReplyCard.tsx


./src/components/illustrations/book-demo/book-demo.tsx


./src/components/task-manager/assign-tasks/TaskItemCard.tsx


./src/components/queries/@questions/overviewSideBar/OverviewComponent.tsx


./src/server/api/services/request/request.service.ts
     } from "@/access/server/accessItemHelpers";
     import type { Context } from "@/server/context";
     import {
    -  type AdditionalRequestData,
    -  type ExtendedRequest,
    +  AdditionalRequestData,
    +  ExtendedRequest,
       ItemType,
    -  type SearchResultEntry,
    -  type SideBarInfo,
...

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载