如何解决VSCode 和 WebStorm 之间的 JSDoc 差异
Atom(带有 atom-typescript
包)和 VSCode 的行为相同,它们都可以为类型文字成员显示 JSDoc:
export type Signer = {
/**
* Produces a cryptographic signature of the input.
*
* @param {Object} input - The input for this function.
* @param {UnsignedMessage} input.unsignedMessage - The unsigned message to be hashed and signed.
* @returns {Signature} An EC signature produces by this signer when signing the message.
*/
readonly sign: (input: {
readonly unsignedMessage: UnsignedMessage
}) => Promise<Signature>
}
您可能会问,为什么使用 type
文字而不是 interface
?我真的不知道,我对 TypeScript/JavaScript 很陌生(来自 Swift 世界......),但我使用 ESLint 插件 functiona
,它有一个 prefer-type-literal
rule,所以我想我应该...... .?
太棒了!但是,两个 IDE 都无法呈现 parameters with properties,例如:
/**
* Assign the project to an employee.
* @param {Object} employee - The employee who is responsible for the project.
* @param {string} employee.name - The name of the employee.
* @param {string} employee.department - The employee's department.
*/
Project.prototype.assign = function({ name,department }) {
// ...
};
为什么使用 input: { name,department }
而不是 (name,department)
?很好地生成更易于阅读的代码,您可以称之为虚拟的“命名参数”——这是我喜欢并依赖于来自 Swift 世界的东西。
完全相反的 JSDoc 行为适用于 IDE WebStorm,其中类型文字成员的 JSDoc 呈现不起作用,但是,具有属性的参数DOES强>工作?♂️。
所以嗯...wtf?这是怎么回事?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。