microsoft / microsoft/TypeScript

Add a refactoring that annotates an implicit or explicit any with a best guess type inferred from its use sites

未关闭
#13,243 17 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Committed Domain: LS: Quick Fixes Suggestion
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

I would very much appreciate having a codefix (refactoring) that, given an explicit any annotation, offers to change it to an {} annotation.

For example, given

function log(x: any) {
  console.log(x);
}

a code fix would be offered to change the declared type of x to {} resulting in

function log(x: {}) {
  console.log(x);
}

However, given

function log(x: any) {
  console.log(x.name);
}

a code fix would be offered to change the declared type of x to { name: any } resulting in

function log(x: {name: any}) {
  console.log(x);
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 TypeScript 的 codefix/refactoring 入口点开始,检查 issue 中显式和隐式 any 的示例。定义支持的使用位置推断情况和预期的替换类型,然后添加有针对性的测试,以展示会提供该重构并生成所请求的注解。

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

评估

技术栈
typescript
领域
compilers
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

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