Page 1 of 1

TypeScript Cannot Find Names

Posted: Fri Feb 03, 2023 3:33 pm
by DtM
Hello,

I've just tried making my first TypeScript file since having Switch Spring 2022.

I used the follow SwitchScriptTool command to make the folder:

Code: Select all

"C:\Program Files\Enfocus\Enfocus Switch\SwitchScriptTool\SwitchScriptTool.exe" --create "SendOrdersToPrinter" .\
After opening main.ts in Visual Studio Code, I'm immeditaley presented with these three errors, which apply to the JobArrive function declaration:

Code: Select all

[{
	"resource": "/d:/ControlFiles/Switch Assets/Scripts/Client Specific/Shell/SendOrdersToPrinter/main.ts",
	"owner": "typescript",
	"code": "2304",
	"severity": 8,
	"message": "Cannot find name 'Switch'.",
	"source": "ts",
	"startLineNumber": 3,
	"startColumn": 30,
	"endLineNumber": 3,
	"endColumn": 36
},{
	"resource": "/d:/ControlFiles/Switch Assets/Scripts/Client Specific/Shell/SendOrdersToPrinter/main.ts",
	"owner": "typescript",
	"code": "2304",
	"severity": 8,
	"message": "Cannot find name 'FlowElement'.",
	"source": "ts",
	"startLineNumber": 3,
	"startColumn": 51,
	"endLineNumber": 3,
	"endColumn": 62
},{
	"resource": "/d:/ControlFiles/Switch Assets/Scripts/Client Specific/Shell/SendOrdersToPrinter/main.ts",
	"owner": "typescript",
	"code": "2304",
	"severity": 8,
	"message": "Cannot find name 'Job'.",
	"source": "ts",
	"startLineNumber": 3,
	"startColumn": 69,
	"endLineNumber": 3,
	"endColumn": 72
}]
I'd assumed that as I used SwitchScriptTool, all of the type definitions should already be setup for me, can someone please assist?

Re: TypeScript Cannot Find Names

Posted: Mon Feb 06, 2023 9:13 am
by freddyp
It is clear that the Switch typings are missing. I have seen this happen before but it is not clear to me what the exact cause is. But if you type:

Code: Select all

npm i
it will be OK (it reinstalls all missing packages defined in the package.json file).

If not, check the package.json file for the link to the Switch typings and try using that link with npm i.