VisualStudioCode reports messages

Post Reply
marsch
Newbie
Posts: 2
Joined: Fri Nov 08, 2013 1:19 pm

VisualStudioCode reports messages

Post by marsch »

Hi,
after update of Switch to version 25.11 VisualStudioCode (VSC) reports messages that I do not fully understand nor know how to solve

Extract from VSC messages, see also attched screendump

Cannot find name 'Switch'.
[{
"resource": "/c:/Users/eivdt/Documents/122-script-nodejs-ts/filePathChunks/main.ts",
"owner": "typescript",
"code": "2304",
"severity": 8,
"message": "Cannot find name 'Switch'.",
"source": "ts",
"startLineNumber": 8,
"startColumn": 30,
"endLineNumber": 8,
"endColumn": 36,
"modelVersionId": 1,
"origin": "extHost1"
}]

Cannot find name 'FlowElement'.
[{
"resource": "/c:/Users/eivdt/Documents/122-script-nodejs-ts/filePathChunks/main.ts",
"owner": "typescript",
"code": "2304",
"severity": 8,
"message": "Cannot find name 'FlowElement'.",
"source": "ts",
"startLineNumber": 8,
"startColumn": 51,
"endLineNumber": 8,
"endColumn": 62,
"modelVersionId": 1,
"origin": "extHost1"
}]

VSC is updated. npm is updated to version 11.12.1. Did not help.

What has happned?
How can this be solved?

Best regards
Martin
Attachments
vsc-cannot-find.png
vsc-cannot-find.png (35.76 KiB) Viewed 501 times
User avatar
samw
Newbie
Posts: 10
Joined: Fri Jan 09, 2026 3:31 pm
Location: UK
Contact:

Re: VisualStudioCode reports messages

Post by samw »

Hi Martin,

This is not caused by the upgrade to Switch 25.11 but by a very recent VS Code update. VS Code now uses TypeScript 6.0 which requires ambient/global type definitions (such as the switch-scripting type definitions) to be explicitly included in tsconfig.json, and deprecates moduleResolution="node".

We are making sure that script folders created with the next Switch version are compatible, but any existing script folders created in Switch 25.11 or earlier will need to be updated accordingly, if using a recent VS Code version which depends on TypeScript >=6.0.

There are basically two approaches:
  • Update tsconfig.json to make the project compatible with TS v6 (potential for conflict with existing SwitchScriptTool)
  • Set up VS Code for compatibility with older TypeScript version (v4.6.3 for Switch 24 Fall and 25.11)
I would suggest the latter, which can be done like this:

1. Install TypeScript 4.6.3 as a dev dependency:

Code: Select all

npm i --save-dev typescript@4.6.3
2. Create .vscode/settings.json with the following content:

Code: Select all

{
    "typescript.tsdk": "node_modules/typescript/lib"
}
3. Open VS Code command pallette (Ctrl/Cmd + Shift + P)
Search/select "TypeScript: Select TypeScript version..."
Choose "Use workspace version (4.6.3)"

Now everything will work as expected.
User avatar
samw
Newbie
Posts: 10
Joined: Fri Jan 09, 2026 3:31 pm
Location: UK
Contact:

Re: VisualStudioCode reports messages

Post by samw »

In case anyone has trouble attempting the workaround in my previous reply, please note that the Typescript commands are only available in the VS Code Command Palette if a .ts file is open in the active tab.
jan_suhr
Advanced member
Posts: 706
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: VisualStudioCode reports messages

Post by jan_suhr »

It might be an idea to add this information to the Script Documentation. I had the same problem and got help from Freddy to fix it.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
marsch
Newbie
Posts: 2
Joined: Fri Nov 08, 2013 1:19 pm

Re: VisualStudioCode reports messages

Post by marsch »

Hi,
I tried this and I do not get it to work. Tried both the script folder and a more global folder. Nope, sorry I do not get it right.

Questions
Where to exactly install TypeScript 4.6.3?
In the script folder herarchy ...\node_modules\typescript?

There are several .vscode folders.
In which one should .vscode/settings.json be placed?

When doing a search for TypeScript, nothing is found, see attached screendump.

What am I doing wrong?

/Martin
Attachments
vsc-search-typescript.png
vsc-search-typescript.png (12.92 KiB) Viewed 315 times
freddyp
Advanced member
Posts: 1184
Joined: Thu Feb 09, 2012 3:53 pm

Re: VisualStudioCode reports messages

Post by freddyp »

Code: Select all

npm i typescript@4.6.3
installs that version of TypeScript in your script folder and then you will see that the workspace version is available in the Command Palette.
User avatar
samw
Newbie
Posts: 10
Joined: Fri Jan 09, 2026 3:31 pm
Location: UK
Contact:

Re: VisualStudioCode reports messages

Post by samw »

As Freddy mentioned, this is all local to the script folder. So the settings file should be created in the .vscode/ subfolder within your script folder, and Typescript should be installed as a dev dependency of your script.

This has to be done for every script folder unfortunately – there is no global 'fix', because the existing tsconfig.json is not compatible with TypeScript 6. We are also considering how upgrading script folders can be made easier in the future to help resolve this type of issue.

If you are happy to ignore the depreciation warning for "moduleResolution": "node", you can ignore all of this and simply add to your tsconfig.json:

Code: Select all

"types": ["node", "switch-scripting"]
This is how new script folders will be created in the next release. That deprecation warning can to be ignored as SwitchScriptTool is bundled with a compatible version of TypeScript (and node), and the transpile will not complain.

This information will be included in the documentation for the next release and will be communicating the details to app creators and scripting users next week.
Post Reply