为什么在过滤映射键时未显示JSDOC评论?
我正在尝试为类创建一个配置类型。我希望该类型将所有属性作为可选的,但没有类的功能。类似于“部分”但没有功能。我有效,但是IDE不再显示JSDOC的评论。
Here's what I have:
type Config<T> = {
[P in keyof T as (T[P] extends Function ? never : P)]?: T[P];
};
class Person {
/**
* JSdoc must show for ID;
*/
public name = "";
/**
* I don't want to have this one in Config
*/
public fn() {
}
}
const config: Config<Person> = {name : "test"};
const config2 : Partial<Person> = {name: "test"};
With config2 the jsdoc hint shows but for Config it doesn't.有人知道如何使它起作用吗?
I'm trying to create a config type for a class. I want the type to have all the properties as optional but without the functions of the of the class. Similar to "Partial" but without functions. I have it working but the IDE no longer shows the jsdoc comments.
Here's what I have:
type Config<T> = {
[P in keyof T as (T[P] extends Function ? never : P)]?: T[P];
};
class Person {
/**
* JSdoc must show for ID;
*/
public name = "";
/**
* I don't want to have this one in Config
*/
public fn() {
}
}
const config: Config<Person> = {name : "test"};
const config2 : Partial<Person> = {name: "test"};
With config2 the jsdoc hint shows but for Config it doesn't. Does anybody know how to get this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
钥匙过滤器将丢失JSDOC。但是省略和选择不会!
尝试:
Key filter will lose JSDoc. But Omit and Pick won't!
Try: