Missing code completion

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

User avatar
Rob
Posts: 53
Joined: 01 Jul 2017, 07:33

Missing code completion

Postby Rob » 29 Jul 2019, 17:00

For some reason I'm not getting IntelliSense working for the smartfox API when using the client npm package. All other installed npm packages work fine and give me code completion, so I suspect it has something to do with how it's packaged.

I'm using IntelliJ IDEA, but I also tried it in VSCode and it's not working there either.

In IntelliJ I get these "weak warnings" everywhere I use a smartfox method and it's pretty annoying.

UnresolvedType.png
(37.18 KiB) Not downloaded yet

Is there some configuration I can do on my end to fix this, or does the package itself need to be fixed?
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Missing code completion

Postby Bax » 30 Jul 2019, 08:22

IntelliSense in those environments requires a types definition file to be provided.
We don't have such file available, because as of today we could not find a way to generate it automatically (at least the tree of classes, methods, etc).
I guess you will need to configure Intellij so that it is not reporting those warnings.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Missing code completion

Postby Bax » 30 Jul 2019, 10:04

We have a partial solution to this issue.
Using the tool at the url below, you can make it generate a d.ts file for our API, which I think should stop your IDE from complaining.
We will figure out if we can distribute a d.ts file together with the API. But currently I'm not 100% happy with the result. In fact the tool processes the "compiled" version of our API, which doesn't include JSDoc. We have to further investigate if it is possible (and how) to generate a better d.ts file, but for now it should be enough for you.
Hope this helps.

https://github.com/Microsoft/dts-gen
Paolo Bax
The SmartFoxServer Team
User avatar
Rob
Posts: 53
Joined: 01 Jul 2017, 07:33

Re: Missing code completion

Postby Rob » 30 Jul 2019, 10:51

I'm pretty sure IntelliSense doesn't require type definitions to work. Granted, type info is really good to have and will expand the code suggestions so I'm all for adding that! But even without type definitions it should be possible to get basic things like method name suggestions.

We get code completion for our own code and we don't use types. Simple things like typing myLib.a will pop up all methods starting with a in our myLib package.

For some reason the IDE doesn't seem able to parse and index your library. I noticed that the npm package is minimized, which is unusal. Maybe this causes problems? Or something else with transpilation is messing things up?
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Missing code completion

Postby Bax » 07 Aug 2019, 07:30

In today's JavaScript programming there's so many layers (web pack or other bundlers, transpiration, npm, etc) and styles in writing the code which is almost impossible to understand what is going on and where.
I still think the issue here is the missing type definitions file. Also check this thread on StackOverflow: https://stackoverflow.com/questions/455 ... ck-bundles
Other threads also state the same.
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Missing code completion

Postby Bax » 08 Aug 2019, 09:17

Rob, we have found a way to generate a d.ts file more easily and including the jsdoc. Still not perfect, but quite good.
If you want to give it a try in your dev environment, just send us an email referencing this thread.
Thanks.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 21 guests