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
I know this is a old question, but I got to the same problem.
I think that there is a feature now related to the file jsconfig.json .
Putting this file in the root folder, I could get the intellisense for functions and objects methods, look these examples below.
(note: in the case of object methods, the object needs to be define with the let
statement)
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.