如何记录引用对象字面量中的类型的对象?
我有以下场景:
var myNamespace = {
/**
* @type {myNamespace.MyClass|undefined}
*/
myObject: undefined,
MyClass: class MyClass {
},
MyOtherClass: class MyOtherClass {
/**
* @type {myNamespace.MyClass}
*/
myProperty
}
}
是否可以以某种方式记录这一点,使 Visual Studio Code 可以给我建议,而不使用 @typedef,如果可以,我将如何处理?
我尝试了各种不同的格式,但每次结果都是相同的,我得到“Type = /*unresolved*/any”。 在命名空间内部和外部,结果似乎是相同的。
我可以以复杂的细节记录对象(“myNamespace”),但它仍然会引用其自身内部的类型,我怀疑这是可能的吗?
I have the following scenario:
var myNamespace = {
/**
* @type {myNamespace.MyClass|undefined}
*/
myObject: undefined,
MyClass: class MyClass {
},
MyOtherClass: class MyOtherClass {
/**
* @type {myNamespace.MyClass}
*/
myProperty
}
}
Is it possible to document this in a way to make visual studio code can give me suggestions, without using @typedef, and if so, how would I go about it?
I have tried various different formats, but every time the result is the same where I get "Type = /*unresolved*/ any".
Both inside and outside of the namespace the result seems to be the same.
I would be ok with documenting the object ("myNamespace") in complex detail, but it would still refer to types inside of itself, which I doubt is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论