Consider folder structure as below in javascript project built-in Visual Studio 1.43
/Folder1
/testFunctions1.js
/function1()
/function2()
...
/Folder2
/testFunctions2.js
require('testFunctions1.js') //to include
functio //Here If I press ctrl+space, I expect suggestions of functions defined in testFunctions1.js
How do I achieve it in java-script?
pre-reqs: javascript/Visual Studi 1.43 (2020)
Update 1:
../Folder1/testFunctions1.js
test1 : function()
{
..
..
}
test2 : function()
{
..
..
}
../Folder2/testFunctions2.js
require('../Folder1/testFunctions1.js')
test (ctrl+space) //expect suggestions here
Update 2:
function doSomething1() {
..
}
function doSomething2() {
..
}
If I include above with reference, I get suggestions - It works.
But If I have functions in below format then, it fails. I want doSomething in suggestions.
//testFunctions1.js
define('../mypageobjects/PageObject.js',
[
'../test/tests.js'
],
function (PageObject,commonLibWidget){
var test = PageObject.extend('test', {
check: function () {
return true;
},
selectors: {
//home page
widgetHeader: '.moduleHeader_tle',
},
commands: {
doSomething1: function(){ //I want this function name - doSomething1
return this
},
doSomething2: function(){ //I want this function name - doSomething2
return this
},
} //commands close
}); //pageobject.extend
return test;
}); //main function
Try adding the following comment to the top of your testFunctions2.js
file:
/// <reference path="../Folder1/testFunctions1.js" />
This should work in Visual Studio and VSCode.
See also: What is reference path in vscode