-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript support #998
Comments
I'm not sure this is the highest priority, but it would be a lovely thing to have. Is the JS interpreter sufficiently close to standard that this would work at present? |
Good point! I personally would enjoy contributing to this endeavor |
I think @T0TProduction may have already seen this, but there is already one Typescript app called BangleRun: https://github.com/espruino/BangleApps/tree/master/apps/banglerun On the whole Espruino seems fine with the minified code that comes out of Typescript, and adding apps in the way BangleRun did seems like a definite possibility (with the TypeScript source but minified JS stored to get uploaded, and build instructions in a README). However my concern is really with maintainability. BangleRun is a great example - it was written in thoughtful way, but the original maintainer stopped contributing after a while, and then when there are issues it falls down to the community. And that meant me, because nobody else dared poke around in it. Actually debugging/fixing stuff like this is a nightmare. So you get a stack trace in JS? You've then got to search through the minified JS and try and find the matching bit, and then try and guess where in the Typescript it was. And then when you find it, you've got this maze of totally undocumented spaghetti code to wade through. It feels like when you're writing apps that you submit you shouldn't just be thinking about 'how can I make this easy for myself', but 'how can I make this easy for others to contribute'. I feel like with BangleRun the idea was 'I'll use TypeScript to make this easy for everyone, it's self-documenting because it has types' - but in this case, the reality was exactly the opposite... What should have been a simple <200 line app with comments turned into an 8 file, undocumented, unmaintained project written in a different language to every other app. I'm not saying you shouldn't use TypeScript - but just be aware that you may lose interest at some point, and then someone else will have to maintain the code. |
Interesting, I hadn't seen it until now! Concerning maintainability, that's exactly why I suggested building an "official" typing as well as project/build configuration But knowing that in theory it works (as we have a working example), maybe just starting with it and trying to create a shareable MVP (with just a small part of the bangle modules being typed) configuration would be a good next step! If I were to start something, would you want it to be part of this repository? There could be a ~/typescript folder in the root, which includes a package that exports the config and the types |
Yes, a |
The official typing of Bangle seems to be Javascript. I know I sound like a dinosaur but for a platform as this really like to be able and use the core of the language and not (all) the metalanguages and frameworks on top of javascript. Especially for the point Gordon brought up; it's a trend for a while, something even cooler pops up and everyone moves untill the next big thing. I know Typescript is around for a while, but as long as you'd have the option to just use native Javascript and not create a dependency and transpiling hell, I think you are more accessible ad s platform and (maybe even more important) less dependent on 'third-party' infrastructure. |
I agree - the point is not to remove JS support, but add TS support. (which just compiles to JS in the end anyways.) When talking about "typing all modules bangle.js exposes" this means adding type.d.ts files that describe the JS. This does not mean changing the code to TS. |
On a different note, I started working on the first configuration and realized that I was wrong about the following: |
This would be a good plan, yes. But I do think there is still the question: Why do you actually want to do this?
I think I've given a pretty compelling example of something that was a nightmare - I'd just like to know what the actual real benefits this is going to bring before we do something that's going to cause even more of a maintenance headache. |
First, concerning your questions:
The main reason I personally love Typescript is typing (duh). I think these features are a great way to support not only myself, but anyone who wants to (start to) contribute. IMO, this makes the platform more accessible, and more stable at the same time. |
I finished the very first draft of project and type definitions and used the widget I recently added as test-app. (rewritten to TS) |
Will do - I'm just a bit busy right now! |
Let's bring Svelte then. It compiles down to plain JS like TS, easier to debug, but can offer possibilities TS can't. Comparison just by value |
I don't think Svelte does what you think it does? Typescript is an
annotation layer on top of Javascript, which is itself a general purpose
programming language, while—unless I'm utterly confused—Svelte is more like
an attempt to fix dynamic HTML.
…On Fri, 17 Dec 2021 at 09:37, Romanist ***@***.***> wrote:
Let's bring Svelte then. It compiles down to plain JS like TS, easier to
debug, but can offer possibilities TS can't. Comparison just by value
—
Reply to this email directly, view it on GitHub
<#998 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGZ2FVFA42W3H37DAUUHWDURNYNTANCNFSM5JLORQVQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yeah, afaik Svelte is made for building webapps - which bangle apps are not. They cannot display any HTML or CSS. |
yeah, that was silly of me :( |
TypeScript seems will stay with us for a long time. There are people who want to write code only in statically typed languages with interfaces. If such people will write interesting apps for Bangle.js well it would be nice. It would be great to see such an implementation: we connect the extension to the VS Code, write the dev version of the TypeScript there, and the result can be simply run in the Bangle.js emulator. I mean without copy paste in WEB IDE. And as a result will be compilation of the production version with correct JS. |
If you're interested in how the TS implementation currently looks, check out the linked PR! Concerning TS not going away: |
<philosophy>I certainly can't forsee TS going away without anyone writing a
TS->JS converter. I mean, considering that TS itself already is one
;).</philosophy>
…On Tue, 21 Dec 2021 at 14:17, Sebastian Di Luzio ***@***.***> wrote:
If you're interested in how the TS implementation currently looks, check
out the linked PR!
In general I think adding support to the web IDE will be a lot more
difficult.
TS needs build tools, and those aren't made to run in browsers. Definitely
possible, but also definitely not as straight forward as using TS locally.
Concerning TS not going away:
I think we can all agree that the seventh most used language (
https://insights.stackoverflow.com/survey/2021#most-popular-technologies-language)
will not just disappear. TS is here to stay, and that's a fact.
—
Reply to this email directly, view it on GitHub
<#998 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGZ2FUSNOOU4KWMD4DXEFLUSD4I5ANCNFSM5JLORQVQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Ok, just merged the PR for this. Just a note here - any new PR for a TypeScript Bangle.js app that doesn't use what's in #1052 isn't going to be merged |
Im a fan of the simple way this repository hosts app as well as the existence of the web IDE and emulators for ease of use.
One thing I was wondering though:
Is there any Typescript support? Obviously all distributed apps need to be JS, but in theory typing the entire BangleJS environment and creating a default export/transpile script that exports files to the correct format and structure could be a huge help to creating new apps.
The main two questions I would have are:
This can be deactivated, but saves memory etc. so why should we remove that benefit of TS.
A solution to this could be to also add the TS files to the PR, maybe in an extra folder which is used to verify the code logic in PRs, but just ignored by the app loader later on.
A probably overkill solution for the second question could also be to allow TS PRs, and then after approval a GitHub Action transpiles the TS without any human interaction - making sure the potentially unreadable code is actually created with the reviewed TS code.
Edit : there is an open pull request:
#1052
The text was updated successfully, but these errors were encountered: