Skip to main content
Inspiring
October 16, 2020
Answered

Cannot find name of a function from //@included file.

  • October 16, 2020
  • 2 replies
  • 1204 views

Sorry if this is not the right place to ask this type of question. If so, please let me know which forum I should post to.
 
I just started using Visual Studio Code with ExtendScript plug-in. Intellisense works most of the time, but ignores functions from the included files.
 
For example, I have a file with commonly used functions called common.jsx. The file contains a function FindCompByName(name). I include the file with
//@include "E:/After Effects Scripting/common.jsx"
The function can be called from the main script just fine, but VSCode shows a "cannot find name FindCompByName' error.
 
Is it possible to fix that?

This topic has been closed for replies.
Correct answer sberic

Whoops! The jsonconfig.json file is, well, JSON formatted and I incorrectly transcribed the boolean values. To fix the issues, remove the quotes around "true" for the "checkJs" and "strict" lines. It should look like this:

 

{
  "compilerOptions": {
    "checkJs": true,     // Tells VSCode to type check JavaScript [ExtendScript] files.
    "strict": true,      // Turns on all safety checks.
    "target": "es3",     // ExtendScript is ES3.
    "lib": [             // Turns off web DOM API autocomplete.
      "es5"
    ]
  },
  "include": ["./**/*"]  // Include all files in this folder and any beneath it.
}

2 replies

sberic
Legend
October 21, 2020

Yes, this is possible to fix.

 

You need to add either a jsconfig.json or tsconfig.json file to the top folder of your ExtendScript source code directory. I would recommend adding a jsconfig.json file that looks something like this:

 

{
  "compilerOptions": {
    "checkJs": "true",   // Tells VSCode to type check JavaScript [ExtendScript] files.
    "strict": "true",    // Turns on all checks.
    "target": "es3",     // ExtendScript is ES3.
    "lib": [             // Turns off web DOM API autocomplete.
      "es5"
    ]
  },
  "include": ["./**/*"]  // Include all files in this folder and any beneath it.
}

 

Hopefully something like that will get you moving!

Inspiring
October 22, 2020

Thank you! The "Cannot find name of a function" error is gone, but I get a couple of errors like this from jsconfig.json:

 

Compiler option 'checkJs' requires a value of type boolean.

sberic
sbericCorrect answer
Legend
October 22, 2020

Whoops! The jsonconfig.json file is, well, JSON formatted and I incorrectly transcribed the boolean values. To fix the issues, remove the quotes around "true" for the "checkJs" and "strict" lines. It should look like this:

 

{
  "compilerOptions": {
    "checkJs": true,     // Tells VSCode to type check JavaScript [ExtendScript] files.
    "strict": true,      // Turns on all safety checks.
    "target": "es3",     // ExtendScript is ES3.
    "lib": [             // Turns off web DOM API autocomplete.
      "es5"
    ]
  },
  "include": ["./**/*"]  // Include all files in this folder and any beneath it.
}
erinferinferinf
Adobe Employee
Adobe Employee
October 21, 2020

This is a great place to ask this question. Maybe @sberic is the right person to answer... (and I want to point out that I could '@' him now!)

 

Here's his long ExtendScript Debugger thread, if you haven't seen it.