Git Product home page Git Product logo

Comments (7)

EdJoPaTo avatar EdJoPaTo commented on June 3, 2024 1

These compiler options only help, as far as i understand, to import things into your lib. The types have to be correct for that in the first place. (Correct me if im wrong!)

The problem in this case is the duplicate export of the common types.
The library exports methods like isPropertyId and the WDK function and the object returned also contains the common methods.

Normally you would create a namespace and the function with the same name and export that to follow the JS code. But you can not export * from from within namespaces which creates a lot of method: typeof method stubs. On the returned interface you have to do the same which creates a lot of typing code just for that. (which is also prone to errors when something changes)

Having the default export you can simply export * from without the need for the extra namespace and have way less typing code. Also i didnt exported the common methods from the returned object which also simplified the typing code a lot (but thats far from perfect typings).

Personally I think the time invested to type this could be also spent to refactor things. But thats up to everyone themselves. I only started to look differently onto source code since I started using TypeScript and I am not used to code which is used in front end / browsers. The way this library is built certainly has its purpose.

from wikibase-sdk.

maxlath avatar maxlath commented on June 3, 2024

new version without the types: v7.0.8

from wikibase-sdk.

r3mi avatar r3mi commented on June 3, 2024

Hello,
is there a status on TypeScript typings ?
looking around in the issues, it seems there used to be typings but they have been deleted ? It seems also there was typings on DefinitelyTyped but they have been deleted as well ?
is there an update on this ?

Thanks for your library ,

from wikibase-sdk.

maxlath avatar maxlath commented on June 3, 2024

@r3mi types were added for v6, but then v7 brought some breaking changes and those types became obsolete so were removed. I don't see any breaking change coming, so if anyone wants to update types for v7, I would be ok to merge them back. I still don't use Typescript for now, so I can't do the maintenance of those, but it seems that enough people are interested to make it happen and keep those updated.

from wikibase-sdk.

EdJoPaTo avatar EdJoPaTo commented on June 3, 2024

I created the wikibase-types npm package for types returned by the wikibase / wikidata API. Its helpful but still not as good as a fully typed library.

If someone has the time: The typings from #69 could be used to type this library on DefinitelyTyped but without this change the typings seem to get way more complicated than in #69. (Maybe I have overlooked something?)

from wikibase-sdk.

noinkling avatar noinkling commented on June 3, 2024

without this change the typings seem to get way more complicated than in #69. (Maybe I have overlooked something?)

That seems weird to me, usually it's not up to the library to write hacks to ensure compatibility between CommonJS and ES modules. I thought that was what the allowSyntheticDefaultImports TS compiler option did (although there are other options that can enable it implicitly), or maybe esModuleInterop.

from wikibase-sdk.

maxlath avatar maxlath commented on June 3, 2024

Closing in favor of #82

from wikibase-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.