Typescript compile error in index.d.ts

Post Reply
carlTI5
Newbie
Posts: 7
Joined: Wed Aug 18, 2021 11:41 am

Typescript compile error in index.d.ts

Post by carlTI5 »

The following error is thrown when using SwitchScriptTool to compile to a sscript file:
Error: TypeScript standard output: C:/Program Files/Enfocus/Enfocus Switch/SwitchScriptTool/obfuscator/node_modules/@types/switch-scripting/index.d.ts(880,3): error
TS7010: 'close', which lacks return-type annotation, implicitly has an 'any' return type.
C:/Program Files/Enfocus/Enfocus Switch/SwitchScriptTool/obfuscator/node_modules/@types/switch-scripting/index.d.ts(1208,3): error TS7010: 'close', which lacks return-type annotation, implicitly has an 'any' return type.
And then after re-installing @types in local project the error is thrown from the index.d.ts in the switch-scripting local.
Error: Failed to transpile the code: TypeScript failed with exit code 2
Error: TypeScript standard output: node_modules/@types/switch-scripting/index.d.ts(772,3): error TS7010: 'close', which lacks return-type annotation, implicitly has
an 'any' return type.

Can anybody suggest a reason for this, as this is internal to the Enfocus Script Tool? I have attached a screenshot of the error shown in the index.d.ts as is in the switch-scripting folder.
Attachments
index.d.ts.png
index.d.ts.png (114.85 KiB) Viewed 5157 times
patej
Member
Posts: 79
Joined: Sun Nov 25, 2012 12:15 pm

Re: Typescript compile error in index.d.ts

Post by patej »

I haven't encountered exactly that, but the line numbering in your index.d.ts doesn't match mine so what version of types-switch-scripting are you including in your project? When you create a new script folder with Switch 2021 Fall, the line in its package.json is:

Code: Select all

"@types/switch-scripting": "https://github.com/enfocus-switch/types-switch-scripting/archive/21.1.0.tar.gz"
I had a different problem earlier and the reason was that there was a mismatch with the types-switch-scripting version included in a script folder that was created in a previous version of Switch (2020 Fall at the time) vs the one the updated Switch (2021 Spring) expected so I had to update that to get it working. Maybe that could help in this case, too?
carlTI5
Newbie
Posts: 7
Joined: Wed Aug 18, 2021 11:41 am

Re: Typescript compile error in index.d.ts

Post by carlTI5 »

That line was as follows:
"@types/switch-scripting": "https://github.com/enfocus-switch/types ... 1.0.tar.gz"

This was an old project that came over from the previous version of Switch.

Manually updated the package.json & package-lock.json to the below:
"devDependencies": {
"@types/node": "16.11.6",
"@types/switch-scripting": "https://github.com/enfocus-switch/types ... 1.0.tar.gz"
},
Still did not transpile.

Made a new empty project to check what index.d.ts is under the new version of Switch. That line is still close();. No return type specified.

Project then transpiled by either specifying in index.d.ts:
close():any;
Or changing code to:
// @ts-ignore
close();
carlTI5
Newbie
Posts: 7
Joined: Wed Aug 18, 2021 11:41 am

Re: Typescript compile error in index.d.ts

Post by carlTI5 »

On further thought that line should probably be:
close():void;
patej
Member
Posts: 79
Joined: Sun Nov 25, 2012 12:15 pm

Re: Typescript compile error in index.d.ts

Post by patej »

OK well that sounds like a bug then – could you file a support case via Enfocus Customer Portal?

--patrik
carlTI5
Newbie
Posts: 7
Joined: Wed Aug 18, 2021 11:41 am

Re: Typescript compile error in index.d.ts

Post by carlTI5 »

Yes, could do. Would be interested to know what they come back with.
freddyp
Advanced member
Posts: 1009
Joined: Thu Feb 09, 2012 3:53 pm

Re: Typescript compile error in index.d.ts

Post by freddyp »

The problem appears because you are probably using a tsconfig.json file which contains the compiler flag noImplicitAny.

I logged it and it will be corrected in the typings file. As a temporary workaround you could remove that compiler flag.
carlTI5
Newbie
Posts: 7
Joined: Wed Aug 18, 2021 11:41 am

Re: Typescript compile error in index.d.ts

Post by carlTI5 »

It would have been this line in tsconfig under compiler options:
"strict":true,

that would have been picking up that no return type was being explicitly stated.

Thanks for the feedback.
davyverstaen
Newbie
Posts: 3
Joined: Wed Jan 26, 2022 4:35 pm

Re: Typescript compile error in index.d.ts

Post by davyverstaen »

Hey, this issue has been solved in Switch 2022 Spring.
Post Reply