Cloud Native 10 min read

Unifying TypeScript and Dart for a Serverless FaaS Platform at Xianyu

Xianyu unified its front‑end TypeScript and back‑end Dart by building a source‑to‑source translator that converts TS syntax, maps native methods, bridges business frameworks and dependencies, enabling a single scaffold to manage FaaS projects, reducing silos and streamlining serverless development.

Xianyu Technology
Xianyu Technology
Xianyu Technology
Unifying TypeScript and Dart for a Serverless FaaS Platform at Xianyu

Xianyu's Serverless infrastructure shifted toward the Dart ecosystem, unifying the language for front-end and back-end to improve FaaS development efficiency.

The main obstacles were language disunity and fragmented engineering: front-end developers faced a steep learning curve due to unfamiliar Dart and its ecosystem, while separate front-end and FaaS projects duplicated build, debug, and release toolchains.

To solve this, a TypeScript-to-Dart source-to-source translator was built. The translator works in four layers: (1) basic syntax conversion, (2) native method differences (e.g., list2.push(10) in TS becomes list2.add(10) in Dart, resolved via the TS TypeChecker to map methods to their originating classes), (3) business framework bridging (generating declaration files for services like HsfServices.request and data models such as DartMtopResult), and (4) dependency and header bridging (mapping NPM packages to Dart pub dependencies via a faas.yaml file).

An example of the generated declaration is shown below:

export declare class HsfServices { static request(moduletName: string, parameter: string): Promise<DartMtopResult<string>>; }

For dependency mapping, a faas.yaml specifies the Dart package and entry point:

faas_pub:
  hsf_services: ^1.1.7
  index: hsf_services.dart

Engineering integration followed: the front-end scaffold now fully manages the FaaS project, exposing only init and dev commands, while a real-time compiler syncs translated Dart code into the black-boxed FaaS runtime.

The result is a unified technology stack that gives developers a familiar TypeScript experience, eliminates engineering silos, and provides a smooth path toward further initiatives such as data-structure unification and automated packaging.

Future work includes refining debugging, publishing, rollback mechanisms, and extending the approach to other language pairs.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DARTFaaSServerlessTypeScript
Xianyu Technology
Written by

Xianyu Technology

Official account of the Xianyu technology team

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.