Giter Club home page Giter Club logo

Comments (11)

gfwilliams avatar gfwilliams commented on July 16, 2024 1

Actually I realise the directory I linked also links to https://github.com/espruino/Espruino/blob/master/TYPESCRIPT.md which explains about auto-generating the typescript - a lot of work has gone into that, so if we can find any way to not hand-write TS declarations that would be way better.

I feel like probably we need a generic (non-bangle.js) export and to then try and get @types/espruino updated, ideally with some instructions in there pointing back to https://github.com/espruino/Espruino/blob/master/TYPESCRIPT.md to that folks in future know how to update it

from espruinotools.

gfwilliams avatar gfwilliams commented on July 16, 2024

Hi,

Thanks - yes, the documentation for TypeScript on Espruino isn't great

@bobrippling when you have a moment, would you be able to jump in and provide some pointers? @bobrippling has done a huge chunk of Typescript work, especially for Bangle.js, and I believe most of that is now auto-generated: https://github.com/espruino/BangleApps/tree/master/typescript

from espruinotools.

bobrippling avatar bobrippling commented on July 16, 2024

Hey - yes I'm not familiar with @types/espruino but I'd be happy to take a look over PRs to update it if that's what you're thinking? Let's go through the problems you found when trying to run it too, we can see what we can improve there.

How have you found setting up the repo you referenced?

from espruinotools.

2234839 avatar 2234839 commented on July 16, 2024

I tried updating scripts/build_types.js so that the espruino.d.ts it generates matches the type definitions (http://www.espruino.com/Reference#software) in the official api documentation

from espruinotools.

bobrippling avatar bobrippling commented on July 16, 2024

Cool, do you have the branch for this?

from espruinotools.

2234839 avatar 2234839 commented on July 16, 2024

Cool, do you have the branch for this?

I am reading through the code;
I find that scripts/build_types.js generates much better type files than the npm lib @types/espruino, so why hasn't @types/espruino been updated.
In addition, I can see that some of the type definitions could be optimized, for example, function getDetails(callback?: any): any; The callback here could be better defined, so that the user knows the type of the callback function's arguments.

from espruinotools.

gfwilliams avatar gfwilliams commented on July 16, 2024

so why hasn't @types/espruino been updated.

That's a good question - maybe you could submit a PR to the project?

I can see that some of the type definitions could be optimized

If you see something you want changing you are welcome to contribute updated typings. If you find the relevant file (which you can do by going to https://www.espruino.com/Reference#software, finding the function and clicking => in the title) you can add typescript as mentioned in https://github.com/espruino/Espruino/blob/master/TYPESCRIPT.md to improve the automatic generation.

from espruinotools.

2234839 avatar 2234839 commented on July 16, 2024

I'm writing a simple type inference script, and during debugging I realized that
JsVar *jswrap_wifi_getDetails(JsVar *jsCallback) {{ Is the {{ here a clerical error, when in fact only a { is needed (This is inferred from my experience with js.)

图片

from espruinotools.

gfwilliams avatar gfwilliams commented on July 16, 2024

I don't see any `{{ in that screenshot? But that file is C, not JS

from espruinotools.

2234839 avatar 2234839 commented on July 16, 2024

I don't see any `{{ in that screenshot? But that file is C, not JS

https://github.com/espruino/Espruino/blob/62546cca3a8cebeee7ccb6fd7a4a89d2b973e61d/libs/network/esp8266/jswrap_esp8266_network.c#L742C1-L742C52

The end of this line

from espruinotools.

gfwilliams avatar gfwilliams commented on July 16, 2024

Ahh, sorry - didn't spot that! Yes, that's a typo. It won't affect the code, but it's a bit ugly for sure - just fixed it

from espruinotools.

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.