Reports not properly written for Typescript

Stimulsoft Reports.JS discussion
Post Reply
martytheman
Posts: 7
Joined: Thu Nov 23, 2017 11:32 pm

Reports not properly written for Typescript

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Reports not properly written for Typescript

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Reports not properly written for Typescript

Post 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.
martytheman
Posts: 7
Joined: Thu Nov 23, 2017 11:32 pm

Re: Reports not properly written for Typescript

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Reports not properly written for Typescript

Post 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.
paillave
Posts: 1
Joined: Fri Jan 21, 2022 12:04 pm

Re: Reports not properly written for Typescript

Post 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.
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Reports not properly written for Typescript

Post 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.
wprmdev
Posts: 15
Joined: Fri Jun 07, 2019 6:52 pm

Re: Reports not properly written for Typescript

Post 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();

wprmdev
Posts: 15
Joined: Fri Jun 07, 2019 6:52 pm

Re: Reports not properly written for Typescript

Post 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();
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Reports not properly written for Typescript

Post by Lech Kulikowski »

Hello,

Thank you for the detailed information.

Thank you.
Post Reply