Merge pull request #2062 from qucchia/typescript

Typescript
master
Gordon Williams 2022-07-28 08:38:39 +01:00 committed by GitHub
commit a751c0cca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3280 additions and 2168 deletions

View File

@ -1,7 +1,10 @@
# Bangle.ts # Bangle.ts
A generic project setup for compiling apps from Typescript to Bangle.js ready, readable JavaScript. A generic project setup for compiling apps from Typescript to
The types are now automatically generated by a script (see below), although they are still a work-in-progress. Bangle.js-ready, readable JavaScript.
The types are now automatically generated by a script (see
[here](https://github.com/espruino/Espruino/blob/master/TYPESCRIPT.md).
## Compilation ## Compilation
@ -21,13 +24,3 @@ npm run build
``` ```
To build all Typescript apps and widgets. The last command will generate the `app.js` files containing the transpiled code for the Bangle.js. To build all Typescript apps and widgets. The last command will generate the `app.js` files containing the transpiled code for the Bangle.js.
## Generating types
To generate the types, ensure this repository and [Espruino](https://github.com/espruino/Espruino) are in the same folder. From the Espruino folder run:
```
node scripts/build_types.js
```
This will update the file in `types/main.d.ts`.

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,3 @@
// Bangle.js globals
declare const g: Graphics;
type WidgetArea = "tl" | "tr" | "bl" | "br";
type Widget = {
area: WidgetArea;
width: number;
draw: (this: { x: number; y: number }) => void;
};
declare const WIDGETS: { [key: string]: Widget };
// Required for TypeScript to work properly // Required for TypeScript to work properly
interface NewableFunction extends Function {} interface NewableFunction extends Function {}
interface CallableFunction extends Function {} interface CallableFunction extends Function {}