【发布时间】:2020-07-15 21:31:10
【问题描述】:
我想做的是这样的:
class A {
someMethod() {
//
}
}
class B {
constructor (options) {
this.dependency = options.dependency;
}
}
class C extends B {
test() {
this.dependency.a. // want a to refer to instance of A class and provide intellisense using jsdocs
}
}
我在普通对象上尝试了一些东西,它可以工作,但我无法让它在类上工作或覆盖某些属性。 这是我尝试过的:
/**
* @typedef {Object} WithSomeProp
* @property {{ a: A }} prop
*
* @typedef {C & WithSomeProp} extended
*/
/**
* @type {extended}
*/
let a = {};
a.prop.a.someMethod // works (shows suggestion)
a.test // works
/**
* @typedef {Object} WithOtherProp
* @property {{ a: A }} dependency
*
* @typedef {C & WithOtherProp} extendedTwo
*/
/**
* @type {extendedTwo}
*/
let b = {};
b.dependency. // doesn't work
b.test // works
所以总体而言,没有任何方法可以稍后在扩展类上以某种方式覆盖属性定义以获得智能感知支持?
【问题讨论】:
标签: visual-studio-code intellisense jsdoc es6-class javascript-intellisense