问题描述
是否可以将Visual Studio Code(特别是角度开发)配置为自动建议导入文件,该文件包含诸如以下扩展名的方法:
--- map.extensions.ts ---
export {}; // this is a module
declare global {
interface Map<K,V> {
map<R>(fn: (key: K,value: V) => R): R[];
}
}
if (!Map.prototype.map) {
Map.prototype.map = function<K,V,R>(this : Map<K,V>,fn: (key: K,value: V) => R): R[] {
const storage = [];
this.forEach((value,key) => storage.push(fn(key,value)));
return storage;
}
}
请注意,此特定扩展方法的代码与问题无关。重要的是,我们只是扩展类型,并且想要导入.ts文件以使扩展名在我们的应用程序中需要的地方可用。
因此,在我们应用程序的某处,我们将编写如下内容:
---应用。 ts ---
const m = new Map<string,string>();
...
m.map(...);
在这一点上,如果没有import
行,则无法识别此map()
方法。按Ctrl+.
不会提示我们需要的文件。
问题是:在map()方法(在app.ts中)上按Ctrl+.
时,是否可以以某种方式配置VS Code以建议此扩展文件(map.extensions.ts)。 )?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)