Skip to content

Conversation

kpachbiu88
Copy link
Contributor

I faced that in openeo.d.ts were many TypeScript typing errors.

I fixed many errors, and now in VSCode, I can use typing when adding @openeo/js-client library in my project

#70

The best way to add TypeScript support is to refactor the project to TypeScript (replace JSDoc with TypeScript.

@m-mohr
@christophfriedrich

@kpachbiu88 kpachbiu88 changed the title fix most of broken types fix most of broken types openeo.d.ts May 16, 2025
@m-mohr m-mohr self-requested a review May 16, 2025 09:18
@m-mohr
Copy link
Member

m-mohr commented May 16, 2025

Thanks. It's interesting, because we generate this through typescript and thus the obvious question is, why is typescript generating invalid code? Although there's no plan to migrate this project to Typescript, I'm happy to work on making the workflow to provide typescript bindings as smooth as possible. Right now it's a painful process (npm run tsd -> migrate changes manually). If you or anyone else can propose a better workflow, I'm happy to discuss it.

It looks like the three changes are:

  • Use Record instead of object (no brainer, I guess)
  • Change from module OpenEO to namespace OpenEOLib
  • Fix the return value of listServices

Is there anything else that I didn't catch?

@kpachbiu88
Copy link
Contributor Author

Thanks. It's interesting, because we generate this through typescript and thus the obvious question is, why is typescript generating invalid code? Although there's no plan to migrate this project to Typescript, I'm happy to work on making the workflow to provide typescript bindings as smooth as possible. Right now it's a painful process (npm run tsd -> migrate changes manually). If you or anyone else can propose a better workflow, I'm happy to discuss it.

It looks like the three changes are:

  • Use Record instead of object (no brainer, I guess)
  • Change from module OpenEO to namespace OpenEOLib
  • Fix the return value of listServices

Is there anything else that I didn't catch?

Yes, I know about npm run tsd and I tried to change the codebase files to fix openeo.d.ts, but TypeScript generated wrong declaration files openeo.d.ts for me

I do not believe that tsc (typescript) can generate the correct declarations from pure js (JSDoc) now and in the future.

I see only 2 ways:

  • Rewrite the project to TypeScript, it is not a big work, you have tests and JSDoc declarations.
    It helps to project be modern and prevent errors and increase development speed.
  • Add declarations as packet @types/@openeo__js-client Instructions
    Can be as temporal solution of Typescript support

Copy link
Member

@m-mohr m-mohr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

There's no desire to switch to Typescript (JS is as "modern" as TS and the increase in dev speed depends on each developer individually).

How would a separate typescript package with types help compared to having it directly in the @openeo/js-client npm package?

@m-mohr m-mohr merged commit 4a180b6 into Open-EO:master May 16, 2025
1 of 2 checks passed
@kpachbiu88
Copy link
Contributor Author

Thanks.

There's no desire to switch to Typescript (JS is as "modern" as TS and the increase in dev speed depends on each developer individually). How would a separate typescript package with types help compared to having it directly in the @openeo/js-client npm package?

There are no big differences, just one of the ways to add TS support to a JS project

@m-mohr m-mohr linked an issue May 16, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax errors in typescript file?
2 participants