SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
201 stars 28 forks source link

Unneeded writing of interface files #373

Open Revest117 opened 2 years ago

Revest117 commented 2 years ago

As the project I am working on grows, more and more gen.d.ts files are generated. These files are generated every time I save while the ts interface generator is in watch mode. This causes a "spam" of messages in the terminal that eats up the newly generated gen.d.ts, the error messages and other messages.

I would recommend generating all interfaces only at the beginning and then only the files that have changed.

akudev commented 2 years ago

@Revest117 This was an obvious improvement idea from the very beginning and there is actually already code that identifies the changed files (did I mention I hate the prettifier-enforced formatting?).

I'm just not sure whether the solution is as simple as it looks at first glance: can you always easily say what changed? Couldn't changes in a superclass or in other classes or even UI5 itself require a change in a *.gen.d.ts file of an untouched control?

Out of curiosity: about how many generated files and about how much time per generation run are we talking here? We haven't done a load test with many complex files yet.

akudev commented 2 years ago

Actually, https://github.com/SAP/ui5-typescript/blob/main/packages/ts-interface-generator/DEVELOPMENT.md#in-practice has some thoughts on this as well and some change detection details.

Revest117 commented 2 years ago

Currently about 25 .gen.d.ts files are created. It only takes a second, maybe more if my PC is more loaded. The main problem is simply finding the error/warning messages after a few generation cycles in watch mode. In some cases I didn't even notice the warning message because it was pushed up with "Writing interface file: xyz" messages.

I agree that the solution cannot be that simple. But I have an idea to keep the terminal output to a minimum, namely an option to allow only errors/warnings as terminal output.

Currently:

>Writing interface file: xyz
...
>For the type 'abc' an import is created with module name 'cde', using its default export. Is this correct?
Usually this indicates some kind of issue. Maybe this import will also show up as error in your code editor.
The cause of this could be that the type 'abc' is referenced somewhere in Class 'DocumentManager', but is mis-spelled or does actually not exist.
>Writing interface file: cde
...
>Writing interface file: xyz

For a minimum example:

>For the type 'abc' an import is created with module name 'cde', using its default export. Is this correct?
Usually this indicates some kind of issue. Maybe this import will also show up as error in your code editor.
The cause of this could be that the type 'abc' is referenced somewhere in Class 'DocumentManager', but is mis-spelled or does actually not exist.
Writing interface file: cde

>Successfully written XX interface files (6160ms).