如何在 Visual Studio .NET 2008 中保留 JavaScript 全局变量的智能感知
我有一个 JavaScript 包装器,在主体加载时初始化它并设置为全局变量。创建对象后,我就有了完整的智能感知,但是当稍后从另一个函数引用它时,智能感知丢失了。我认为这是因为动态类型:
var myWrapper;
function onload() {
myWrapper = new Wrapper(args);
myWrapper. //Intellisense here.
}
function whatever() {
myWrapper. //Intellisense lost.
}
我通过假装在代码之前再次创建对象,然后删除该行来解决此问题:
function whatever() {
myWrapper = new Wrapper(); //Pretend to create object again.
myWrapper. //Intellisense returns!
}
Has the inference was returned in Visual Studio 2010,或者有什么方法可以告诉 JavaScript关于我目前正在处理的对象类型?
I have a JavaScript wrapper that I initialize on body load and set to a global variable. Just after creating the object, I have full intellisense, but when referring to it later, from another function, the intellisense is lost. I presume this is because of dynamic typing:
var myWrapper;
function onload() {
myWrapper = new Wrapper(args);
myWrapper. //Intellisense here.
}
function whatever() {
myWrapper. //Intellisense lost.
}
I get round this by pretending to create the object again before my code, and then deleting the line:
function whatever() {
myWrapper = new Wrapper(); //Pretend to create object again.
myWrapper. //Intellisense returns!
}
Has the inference been improved in Visual Studio 2010, or is there any way to tell JavaScript about the type of object I'm currently working on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非你告诉它是什么类型(通过使用 new 关键字,否则将很难猜测它是什么......
例如,考虑以下内容
,所以是的,也许允许你的对象被设置(没有像你一样的参数)并将其放在顶部......
Unless you tell is what type it is (by using the
new
keyword, it's going to have a hard time guessing what it is...For example, consider the following
so yeah, perhaps allow your object to be set (Without args as you have) and put it at the top...