我正在使用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」。