microsoft / microsoft/TypeScript
Warn when JSDoc type cast misses parentheses
未关闭
还没有人认领这个 Issue。
Domain: JSDoc
In Discussion
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
Search Terms
jsdoc. type castSuggestion
JSDoc type cast currently requires parentheses for technical reasons (#18212), but it does not warn when they don't exist.
Use Cases
// This doesn't work, the JSDoc comment is silently ignored
// A warning message will help.
const img = /** @type {HTMLImageElement} */ document.getElementById('#cat')
img.src = 'cat.gif'
Examples
const img = /** @type {HTMLImageElement} */ document.getElementById('#cat')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^ Warning: The JSDoc type cast misses parentheses and is being ignored
img.src = 'cat.gif'
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先处理 issue 和所引用的 issue #18212 中描述的 JSDoc 类型转换,然后找到相关的诊断和回归测试。当缺少括号的类型转换在不改变 JavaScript 输出的情况下产生所示警告,同时带括号的类型转换保留当前行为时,这项更改就完成了。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, typescript
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100