Page 1 of 1

Reports not properly written for Typescript

Posted: Wed Jun 24, 2020 12:16 am
by martytheman
Hello.

When using your reports framework in typescript, the stimulsoft.reports.d.ts is not written correctly. Doing this should help you with your development as well as I instantly found a bug in your declaration that was easy to fix.
Maybe you should re-write it in typescript - you would pick up a lot of bugs much earlier in your development life cycle.

File 'node_modules/stimulsoft-reports-js/Scripts/stimulsoft.reports.d.ts' is not a module

I am not a typescript expert - so it would be good if you found the best practice for generating this - but here are some issues I found.

1) I can fix the error above if I do a global replace of
declare namespace
to
export namespace

2) once I have done #1 - VSCode shows me a bug in your declarations:
Property 'draw' in type 'StiMarkerCoreXF' is not assignable to the same property in base type 'IStiMarkerCoreXF'.
Type '(context: StiContext, marker: IStiMarker, position: Point, zoom: number, showShadow: boolean, isMouseOver: boolean, isTooltipMode: boolean, isAnimation: boolean, toolTip: string, tag: any, interaction: StiInteractionDataGeom) => void' is not assignable to type '(context: StiContext, marker: IStiMarker, position: Point, zoom: number, showShadow: boolean, isMouseOver: boolean, isTooltipMode: boolean, isAnimation: boolean, toolTip: String, tag: any, interaction: StiInteractionDataGeom) => any'.
Types of parameters 'toolTip' and 'toolTip' are incompatible.
Type 'String' is not assignable to type 'string'.

Simple to fix - in interface IStiMarkerCoreXF and the draw method ( line 18173 ) , I change toolTip: String to toolTip: string

3) The stimulsoft.reports.d.ts file is massive 2.7MB . It would be a good idea to break down the typesceript definition file into smaller files otherwise you are having to load the whole thing every time youload a report.

Thanks
Martin

Re: Reports not properly written for Typescript

Posted: Thu Jun 25, 2020 3:31 pm
by HighAley
Hello.

Thank you for your questions.
We need some time for analysis and will keep in touch with any news.

Thank you.

Ticket reference: #2317

Re: Reports not properly written for Typescript

Posted: Wed Jul 22, 2020 3:05 pm
by HighAley
Hello.

Here are answers from our developers:

1. The file is created by the compiler. Why do you think that this is wrong?
2. The issue with the types is fixed.
3. This task needs more time. It is in our TODO list.

Thank you.

Re: Reports not properly written for Typescript

Posted: Mon Sep 21, 2020 12:16 am
by martytheman
Hello.

So the problem is that non of your examples are in typescript.

I am forced to use:
var Stimulsoft = require('stimulsoft-reports-js');

When I should be able to use:
import Stimulsoft from 'stimulsoft-reports-js';

If I use the import - it should give me all the typings , and access to all the objects through intellisense AND it should help you find and bugs in your code ( which there appear to be 241 currently )

But it says:
/node_modules/stimulsoft-reports-js/Scripts/stimulsoft.reports.d.ts' is not a module.ts(2306)

Errors like the following show up and it is unusable with a proper import statement.

Errors like:
'text' is defined as a property in class 'BaseTree', but is overridden here in 'CommonTree' as an accessor.

Re: Reports not properly written for Typescript

Posted: Thu Sep 24, 2020 8:33 am
by HighAley
Hello.

Unfortunately, it's impossible to import our scripts this way.
They are too large. Please, use the script tag to load the scripts.

Thank you.

Re: Reports not properly written for Typescript

Posted: Fri Jan 21, 2022 12:34 pm
by paillave
Hello,

A a matter of a fact, yes, there is a problem in "stimulsoft.reports.d.ts" that prevents it to be used as-is in a react front end application. It is certainly due to the fact that the compiler that generated it may not have the necessary options that permits it to be used in a react application. Anyway, every time you publish a new major version of your tools, I struggle for DAYS to have it compiling and working in my very standard react typescript application.
You must realize that the example that is provided on your portal shows a way to develop a react application that NOBODY uses in real life. More over, nowadays most developers use typescript to develop a react application.
I always postpone the moment when I have to update to your latest version of your libraries, because I know I'll struggle during an undefined amount of time to have my application working again.
As it seems your developers are not too used of react with typescript, the way to create an empty react application with type script is this one "npx create-react-app my-app --template typescript". (as described in the official documentation of react: https://create-react-app.dev/docs/adding-typescript/).
I look forward seeing a proper react example on your portal. It is really sad that your documentation is so poor for this matter whereas you clearly have the best reporting eco system on the market to my belief.

Thanks for your understanding.

Re: Reports not properly written for Typescript

Posted: Fri Jan 21, 2022 3:08 pm
by Lech Kulikowski
Hello,

Thank you for the detailed information.
We need some time to change our samples and publish feature. We will let you know about the result.

Thank you.

Re: Reports not properly written for Typescript

Posted: Tue Feb 06, 2024 12:27 pm
by wprmdev
It would be great if imports work correctly with typescript/node. But this was the best solution I found. (Although not the best)

Code: Select all


// This doesn't work. Error: File stimulsoft.reports.d.ts' is not a module
// import Stimulsoft from 'stimulsoft-reports-js';

/// <reference path="../node_modules/stimulsoft-reports-js/Scripts/stimulsoft.reports.d.ts" />
const Stimulsoft = require('stimulsoft-reports-js');

// Execute. But there is no type checking
Stimulsoft.Base.StiFontCollection.addOpentypeFontFile("./Roboto-Black.ttf");
const report: Stimulsoft.Report.StiReport = new Stimulsoft.Report.StiReport();

// Here is OK. It was possible to use the type definition
report.dictionary.databases.clear();


Re: Reports not properly written for Typescript

Posted: Tue Feb 06, 2024 6:40 pm
by wprmdev
This way it is possible to have complete type checking. (It's already something)

Code: Select all

/// <reference path="../node_modules/stimulsoft-reports-js/Scripts/stimulsoft.reports.d.ts" />

const StimulsoftNS: typeof Stimulsoft = require('stimulsoft-reports-js');

StimulsoftNS.Base.StiFontCollection.addOpentypeFontFile("./Roboto-Black.ttf");
const report = new StimulsoftNS.Report.StiReport();
report.dictionary.databases.clear();

Re: Reports not properly written for Typescript

Posted: Tue Feb 06, 2024 9:11 pm
by Lech Kulikowski
Hello,

Thank you for the detailed information.

Thank you.