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
VisualStudioCode reports messages
VisualStudioCode reports messages
- Attachments
-
- vsc-cannot-find.png (35.76 KiB) Viewed 511 times
Re: VisualStudioCode reports messages
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:
1. Install TypeScript 4.6.3 as a dev dependency:
2. Create .vscode/settings.json with the following content:
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.
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)
1. Install TypeScript 4.6.3 as a dev dependency:
Code: Select all
npm i --save-dev typescript@4.6.3Code: Select all
{
"typescript.tsdk": "node_modules/typescript/lib"
}Search/select "TypeScript: Select TypeScript version..."
Choose "Use workspace version (4.6.3)"
Now everything will work as expected.
Re: VisualStudioCode reports messages
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.
Re: VisualStudioCode reports messages
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.
Re: VisualStudioCode reports messages
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
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 (12.92 KiB) Viewed 325 times
Re: VisualStudioCode reports messages
Code: Select all
npm i typescript@4.6.3Re: VisualStudioCode reports messages
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:
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.
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 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.