TypeScript definitions? #6174
Replies: 1 comment
-
Posted at 2017-07-07 by @gfwilliams Hi, I'm afraid there aren't any definitions around, although it would be easy enough to extract the information from the Espruino build process. All the functions are described in 'wrapper files': https://github.com/espruino/Espruino/blob/master/README_BuildProcess.md#wrapper-files- For instance there's a type file for Tern's autocomplete in the Web IDE: http://www.espruino.com/json/espruino.json However that doesn't contain all the info - for instance if you wrote your own tool to look at the JSON comments in the wrappers, you could determine what was definitely supposed to be an integer/float/etc. Having said all that, have you tried running TypeScript-compiled code yet? There was an issue posted up a week or so ago - in that case the TypeScript compiler that was being used created code where functions are used before they're declared. That's fine in normal JS where everything is parsed beforehand, but in Espruino it's parsed as it is executed, so 'Function Hoisting' doesn't work. To get code working in that case you'd ideally need to flip some setting in the transpiler to make it generate code for functions in an order that doesn't rely on the hoisting. Posted at 2017-07-07 by luwar I use Espruino with TypeScript and was a bit disappointed at the time that the Typescript goal of the last campaign was not reached. So I tried to generated a file
But the corresponding jswrap comment is
The important information of parameter address is only in the description. :-( Currently it is required to write the TypeScript type definition by hand but there is always the risk that the type file will become outdated. @gfwilliams: Do you have an idea how it can go on in the long term? Posted at 2017-07-10 by @gfwilliams Potentially we could look at adding some extra fields to the JSON that allow the types to be documented in a more typescript-friendly way? However surely you don't have to describe every API function at that level? I mean, even without that it's still going to be able to check your code and your use of the API functions in a lot of cases (just not all of them). Posted at 2018-01-05 by sberkov Yesterday I submitted tutorial how to use typescript and visual studio code for development. It is located here https://github.com/espruino/EspruinoDocs/blob/master/tutorials/Typescript%20and%20Visual%20Studio%20Code%20IDE.md Posted at 2019-08-11 by pankleks @sberkov can you please regenerate types for latest release? or can you provide your script to do it? thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-07-06 by sfl
I've put the Espruino Pico and Wifi through some paces and have to say I'm very pleased with these boards. Kudos!
I find I'm much more productive coding in TypeScript rather than plain JavaScript, but can't find any TypeScript definitions.
If there are no definitions, I'd be happy to contribute.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions