I am writing automated testing scripts using TestComplete. TestComplete mostly supports Ecmascript 2015, but it has a few quirks that are causing intellisense to not work as I would expect.
Here is two examples of code files:
File: 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;
File: 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;
}
}
The quirks, as I see them are:
module.exports.UsefullStuff = UsefullStuff;
. (This makes it work with TestComplete.) var useful = require('UsefulStuffFileName');
) new useful.UsefulStuff("Hello");
). Is there anyway to configure Visual Studio Code to understand how these files are related and give me intellisense?
Note: If I try the more standard import {UsefulStuff} from './UsefulStuffFileName';
I get an error saying "Unexpected token import" from TestComplete.
This can be done via these steps.
Change the import to look like this:
var { UsefulStuff } = require('UsefulStuff');
Change the instantiation of the class to look like this:
this.usefulStuff = new UsefulStuff("Hello");
Add a file called jsconfig.json
and put this in it:
.
{
"compilerOptions": {
"baseUrl": "."
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.