Page 1 of 1

Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 10:01 am
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.

Re: Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 10:24 am
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?

Re: Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 11:33 am
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();

Re: Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 11:41 am
by carlTI5
On further thought that line should probably be:
close():void;

Re: Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 12:55 pm
by patej
OK well that sounds like a bug then – could you file a support case via Enfocus Customer Portal?

--patrik

Re: Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 2:14 pm
by carlTI5
Yes, could do. Would be interested to know what they come back with.

Re: Typescript compile error in index.d.ts

Posted: Mon Jan 31, 2022 2:41 pm
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.

Re: Typescript compile error in index.d.ts

Posted: Tue Feb 01, 2022 6:21 am
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.

Re: Typescript compile error in index.d.ts

Posted: Thu Jun 16, 2022 10:27 am
by davyverstaen
Hey, this issue has been solved in Switch 2022 Spring.