我正在使用TestComplete编写自动化测试脚本。 TestComplete大多支持Ecmascript 2015,但它有一些怪癖导致intellisense无法按我的预期工作。获取Visual Studio代码以提供自定义Javascript导入的智能感知
这里的代码文件两个例子:
文件:UsefulStuffFileName.js
class UsefulStuff {
constructor(initValue) {
this.initValue = initValue;
}
get someValue(){
return this.initValue + " someValue";
}
doStuff(input) {
return input + " stuff done";
}
}
module.exports.UsefullStuff = UsefullStuff;
文件:WorkingHere.js
var useful = require('UsefulStuffFileName');
class WorkingHere {
constructor() {
this.usefullStuff = new useful.UsefulStuff("Hello");
}
doCoolStuff() {
// I want intellisense options when I type the period after this.usefulStuff
// The options would be someValue, doStuff() and initValue.
// |
// |
// V
let myVariable = this.usefullStuff.someValue;
}
}
这些怪癖,我看到他们是:
- 导出是通过这种风格:
module.exports.UsefullStuff = UsefullStuff;
。 (这使得它与TestComplete工作。) - “导入”赋值给变量(
var useful = require('UsefulStuffFileName');
) - 对象的“新” ING使用变量来访问类(
new useful.UsefulStuff("Hello");
)。
有没有办法配置Visual Studio代码来理解这些文件如何相关并给我智能感知?
注意:如果我尝试更标准的import {UsefulStuff} from './UsefulStuffFileName';
,我会从TestComplete中看到一个错误,说明“Unexpected token import”。