Skip to content

Adding JavaScript/TypeScript to AssemblyScript migration guide #11

Description

@aminya

It would be nice to have a guide for converting an already written JavaScript/TypeScript codebase to AssemblyScript. AssemblyScript can shine in this regard due to its similar syntax.

Things to cover:

  1. Setting up the project:
    • Setting up your Directories
    • Writing build scripts (asc)
    • Setting up the loaders (mostly as-bind loader)

For these asinit can probably help when starting a new project, but when you want to migrate the story is a little different.

  1. Source code
    • How to add types

      • convert number to (i32, f32, etc).
      • convert Arrays (like number[]) to typed arrays (Float32Array, etc) and static arrays (StaticArray)
      • a simple guide about the allowed class sytnax.
    • How to separate or arrange JavaScript calls

      • DOM API
      • other JavaScript functions

Note: I would like this guide to include as-bind, which is a better loader for the start. Even in Rust, there is no need to meticulously allocate and release Arrays, Strings, etc. If someone needed more flexibility and something was not covered by as-bind they can switch to the original loader.

In my opinion, the current AssemblyScript book is more like a reference, and having a practical guide is very necessary.

As a reference, there is this JavaScript => TypeScript migration guide here:
https://www.staging-typescript.org/docs/handbook/migrating-from-javascript.html

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions