TypeScript Cannot Find Names

Post Reply
DtM
Member
Posts: 26
Joined: Tue Aug 04, 2015 3:02 pm

TypeScript Cannot Find Names

Post 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?
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: TypeScript Cannot Find Names

Post 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.
Post Reply