Unable to mark JS functions as not being constructors (TS80002)
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, typescript
调研方向
使用 JavaScript 和 TS80002 在链接的 TypeScript Playground 中重现该行为,然后调查 @this 和 @function JSDoc 提示如何影响构造函数检测。当受支持的注解或推断路径能够阻止函数被分类为构造函数,并恢复编辑器导航所需的预期函数分类时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Bug Report
TS80002 ("This constructor function may be turned to a class declaration") is a useful tool, but, it often breaks syntax coloring and classification of functions for things like out-of-line event handlers. There seems to be no way to mark a function as "not a constructor" (would the @function JSDoc hint maybe serve this purpose?)
🔎 Search Terms
jsdoc typescript constructor ts80002
🕗 Version & Regression Information
- This behavior was introduced after 3.6.2 at some point, and I reviewed the FAQ for entries about TS80002.
⏯ Playground Link
Playground link with relevant code
💻 Code
/**
* @this {HTMLElement}
* @param {MouseEvent} e
*/
function test(e)
{
this.textContent = '500';
}
document.addEventListener('click', test);
🙁 Actual behavior
TypeScript marks the function test as a constructor for a type. As a consequence, too, VSCode marks it as a type, and not a function, which is confusing for navigation purposes.
🙂 Expected behavior
TypeScript should be able to detect that with a @this hint (or @function perhaps?) that this isn't a constructor.
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TypeScript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/TypeScript#64322 · 2 条评论 · 1 个 reaction · 已指派 2 人 ·
-
Possible Improvement
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/TypeScript#64278 · 1 条评论 · 1 个 reaction ·
-
Docs
难度 2/5 1-3 小时 新手友好度 70/100
microsoft/TypeScript#64118 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
microsoft/TypeScript#64094 ·
-
Docs
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/TypeScript#63959 · 5 条评论 ·
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
kubernetes-sigs/prow#953 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
caddyserver/caddy#8046 ·
-
难度 2/5 1-3 小时 新手友好度 86/100
-
L1 recommended for recruits
难度 2/5 1-3 小时 新手友好度 88/100
-
area/entangle bug
难度 1/5 1 小时以内 新手友好度 92/100