Page 1 of 1

TypeScript declarations bug

Posted: 01 Oct 2019, 12:13
by moris
Hello

I tried to use the latest JS API, you added

[NEW] Experimental TypeScript declarations file included, to improve intellisense in IDEs like Visual Studio Code.


but there are such exceptions

Screenshot at Oct 01 13-49-14.png
(229.25 KiB) Not downloaded yet

Screenshot at Oct 01 13-50-28.png
(69.86 KiB) Not downloaded yet

Screenshot at Oct 01 13-50-53.png
(61.16 KiB) Not downloaded yet

Re: TypeScript declarations bug

Posted: 02 Oct 2019, 07:25
by Bax
What IDE are you using? We'd like to be able to reproduce this to see what is going on.
We tested the type definitions in Visual Studio Code and didn't get errors.

Re: TypeScript declarations bug

Posted: 02 Oct 2019, 14:34
by moris
In the sfs2x-api.1.7.15.d.t.s file, where API methods are described, in the send (request: BaseRequest) method description the BaseRequest type is not described in the file.

A similar problem, for example, in method descriptions getIntArray(key: string): array; note that the return type “array” also does not exist, can be replace it with [] or Array <T>

WebStorme 2018.3.6, Angular CLI 8.3.4 webpack default settings

Re: TypeScript declarations bug

Posted: 03 Oct 2019, 12:44
by Bax
The d.ts file is generated automatically, so we don't have control over missing descriptions.
We'll try to figure out something...

Re: TypeScript declarations bug

Posted: 15 Jan 2020, 15:39
by Plaguestrike
hi!

Has any progress been made with this issue? I'm experiencing this exact same issue too.

Here is my development environment:

General info

Editor: Visual Studio Code 1.41.1
OS: macOS Mojave 10.14.6
Node JS: v11.7.0
NPM: 6.5.0

package.json dependencies

"@angular/compiler": "5.2.11"
"ionic-angular": "3.9.3"
"sfs2x-api": "^1.7.15" (although I've tried to import several different ways)

package.json devDependencies
"@ionic/app-scripts": "3.2.1"
"typescript": "^2.9.2"

tsconfig.json

Code: Select all

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/**/*.spec.ts",
    "src/**/__tests__/*.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}




Because I'm using other 'npm run' scripts defined, I wasn't able to manually run webpack, is this likely to be part of my problem?


Thanks

Re: TypeScript declarations bug

Posted: 16 Jan 2020, 09:08
by Bax
It is not clear if you are having issues using the API (connect to SFS, etc), or if it is just a matter of intellisense and code completion.

Re: TypeScript declarations bug

Posted: 21 Jan 2020, 16:05
by Plaguestrike
Bax wrote:It is not clear if you are having issues using the API (connect to SFS, etc), or if it is just a matter of intellisense and code completion.


I don't think the issue I'm having is either of those things, specifically.

I haven't yet got to the point of seeing an API call be made, because there are TypeScript transpile errors that occur once the SFS2X API has been imported, such as Cannot find name 'BaseRequest' - the same errors that moris reported. This happens even without adding any actual commands; simply importing the typescript.

I tried using the HTML5 API in a kind of round-about way, by only referencing it weakly in a JavaScript class and importing that JavaScript class for use in TypeScript, but I couldn't really get that to work.

I really want to use SmartFox in this project, but I also won't be moving away from TypeScript, so I'm really hoping I can get this to work.


Update:

If, as an alternative to using NPM, I download the Client API and add the files into my source code manually:
- sfs2x-api-1.7.15.d.ts
- sfs2x-api-1.7.15.js
- sfs2x-api-1.7.15.js.map

importing via:

Code: Select all

import * as SFS2X from '../../smartfox/sfs2x-api-1.7.15';


I don't get the above errors about BaseRequest and arrays and so on. But, once I instate some code that actually uses the library, I get this error:

Code: Select all

Uncaught TypeError: t.resolve is not a function
    at Object.setNativePromise


The only code I've added is:

Code: Select all

var sfs = new SFS2X.SmartFox();

Re: TypeScript declarations bug

Posted: 22 Jan 2020, 10:23
by Bax
Could you send a very basic project example showing the TypeScript transpile errors?
Possibly the whole project folder, including node modules and all. We tried updating all the tools used to generate our API final package and we'd like to test it. I don't think anything changed in this regards but.. who knows?
If you can create such basic example (with the least amount of dependancies - for example Angular might not be needed for this), please send us the link to download it by email.

Re: TypeScript declarations bug

Posted: 22 Jan 2020, 11:42
by Bax
One more thing.
Could you please try the following?
In the project configuration in which you get those TypeScript transpile errors, go to the node_modules/sfs2x-api folder and edit the type definitions file. Try substituting all occurrences of "{array}" with "{Array}". Do the errors related to that keyword go away in this case? If yes, we may have a hint to fix the issue.
Are other errors reported (other than BaseRequest)? If yes, can you please send us a list?
Thank you.

PS: if you provide a test project as mentioned before, we can check the above ourselves.

Re: TypeScript declarations bug

Posted: 29 Jan 2020, 09:14
by Bax
We are in the process of releasing a new minor update to the JavaScript API. If would be great if you could provide a feedback on my last message, so that if changes are needed, we can make them available in the coming release. Thank you.

Re: TypeScript declarations bug

Posted: 07 Feb 2020, 16:07
by Plaguestrike
Bax wrote:Could you send a very basic project example showing the TypeScript transpile errors?


I've tried using Smartfox in a basic Ionic project (one created using their starter wizard, with just one simple screen). That's about as simple as I'll be able to manage. I looked into creating a simpler project so that it doesn't include Ionic, but I don't know how. I don't know what a simple TypeScript project would look like. I'm not familiar with React or Parcel for example; only Ionic, Cordova and Capacitor.

When you envision people using the SFS HTML5 API, is there consideration given for React/Ionic/Capacitor/Cordova projects? Not in terms of any more sophisticated integration with these, but just in terms of pulling in the SFS2X NPM module in these slightly busier frameworks, that obviously have more dependencies. I'm not talking about a large existing project with even more dependencies still, I'm just talking about the cleanest Ionic project possible.

I understand you might not have the time to do this, but I would be interested to see whether your team are able to spawn an Ionic project (with any combination of TypeScript and tools versions), and have SFS2X import correctly.

Re: TypeScript declarations bug

Posted: 10 Feb 2020, 08:25
by Bax
As you may understand, it is almost impossible for us to test all combinations of frameworks, package managers, development tools and what more, in particular speaking of TypeScript.

Our API package is the most simple NPM package you can think of: 1 JavaScript file with no dependancies. It is hard to tell what is wrong with this. We may try a test with Ionic (with which we are not familiar), but I'm not sure when.

Still, it would help if you could try what I suggested before (go to the node_modules/sfs2x-api folder and edit the type definitions file - see my previous reply).

Re: TypeScript declarations bug

Posted: 10 Feb 2020, 09:56
by Plaguestrike
I did try replacing {array} with {Array} but sadly I still got BaseRequest errors.

Thanks

Re: TypeScript declarations bug

Posted: 23 Mar 2020, 11:25
by Bax
All reported errors should be fixed by the latest 1.7.17 version of the API.

Re: TypeScript declarations bug

Posted: 23 Mar 2020, 12:03
by Plaguestrike
Bax wrote:All reported errors should be fixed by the latest 1.7.17 version of the API.


Thanks, I'll try it out soon!