Trying to use TypeScript with Alloy

There is an example that is setup for TypeScript:

https://github.com/Moddable-OpenSource/pebble-examples/tree/main/hellotypescript

but when I try to build that example, the build fails:

Running Moddable prebuild.
Running mcrun -m ./src/embeddedjs/manifest.json -f x -p pebble/emery -t build -o ./build/mods/emery/mcrun -s tech.moddable.pebble
### -p pebble/emery
# tsc tsconfig.json
error TS6059: File '/home/david/Downloads/pebble-examples/hellotypescript/src/embeddedjs/main.ts' is not under 'rootDir' '/home/david/Downloads/pebble-examples/hellotypescript/build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files'. 'rootDir' is expected to contain all source files.
  The file is in the program because:
    Part of 'files' list in tsconfig.json

  ../../build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files/tsconfig.json:401:3
    401   "/home/david/Downloads/pebble-examples/hellotypescript/src/embeddedjs/main.ts"
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    File is matched by 'files' list specified here.

../../build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files/tsconfig.json:3:3 - error TS5101: Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
  Visit https://aka.ms/ts6 for migration information.

3   "baseUrl": "./",
    ~~~~~~~~~

../../build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files/tsconfig.json:6:3 - error TS5011: The common source directory of 'tsconfig.json' is '../../../../../../../../../src/embeddedjs'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout.
  Visit https://aka.ms/ts6 for migration information.

6   "outDir": "/home/david/Downloads/pebble-examples/hellotypescript/build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files",
    ~~~~~~~~


Found 3 errors in the same file, starting at: ../../build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files/tsconfig.json:3

make: *** [/home/david/Downloads/pebble-examples/hellotypescript/build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/makefile:98: /home/david/Downloads/pebble-examples/hellotypescript/build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/files/main.js] Error 2
Moddable prebuild failed: Command '['mcrun', '-m', './src/embeddedjs/manifest.json', '-f', 'x', '-p', 'pebble/emery', '-t', 'build', '-o', './build/mods/emery/mcrun', '-s', 'tech.moddable.pebble']' returned non-zero exit status 2.

steps to reproduce:

git clone https://github.com/Moddable-OpenSource/pebble-examples.git
cd pebble-examples/hellotypescript/
pebble build

versions:

tsc --version
Version 6.0.2

pebble --version
Pebble Tool v5.0.29 (active SDK: v4.9.127)

Is there a specific version of TypeScript which I should have installed?

I made a ticket for the example in the repo:

https://github.com/Moddable-OpenSource/pebble-examples/issues/4

1 Like

I found some TypeScript examples in the Discord, but they seem to be for PebbleKit or something else. And not for Alloy/code running on the watch:

https://github.com/C-D-Lewis/pebble-dev/blob/master/watchapps/news-headlines/src/ts/index.ts

1 Like

Hey! There has been an update to moddable stuff (which is why the examples are already updated) but we have not updated our SDK yet. We will update the SDK shortly though!

2 Likes

(post deleted by author)

1 Like

This seems to be solved: Can't get typescript example to work · Issue #4 · Moddable-OpenSource/pebble-examples · GitHub

Note that you need to use TypeScript version 5.
And then only emery and gabbro are supported

1 Like