benjamn / benjamn/ast-types

Removing TSPropertySignature node adds commas to the type declaration

未关闭
#653 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
1.2k
派生
195
平均合并
22 小时 43 分钟
30 天内合并 PR
10

描述

I originally opened this issue on the jscodeshift project (facebook/jscodeshift#464), but I'm pretty sure it is originating on this library.
Basically when you try to remove a type property of a type definition you get unneeded commas like it was an object.
This only happens for typescript, if you use flow you have to use ObjectTypeProperty that works correctly.

Input:

```ts
type Props = {
__: translator;
form: Form;
isOpen: boolean;
closeModal: () => void;
};
```

Execute:

```ts
j(file.source).find(j.TSPropertySignature, { key: { name: "__" } }).remove();
```

Output:

```
type Props = {
form: Form;,
isOpen: boolean;,
closeModal: () => void;
};
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

使用提供的 TypeScript 类型定义和移除 TSPropertySignature 的 jscodeshift 查询重现该问题。跟踪 TypeScript 属性的移除和打印路径,并将其与 Flow ObjectTypeProperty 的行为进行比较。当剩余属性以分号打印且没有额外逗号时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。