Skip to content
Jonathan Rezende edited this page Apr 11, 2023 · 3 revisions

Disclaimer: This package is in Beta and should work only with Dart 3 onwards.

You can help in many ways

  • Directly add packages and submit PR. Refer to the add package section in this wiki.
  • Help deciding on how to transpile better Dart code. More info below.
  • Fix transpiler issues by submitting PRs
  • Create issues for the bugs you hit on.
  • Sponsoring/donating. Even thought I do this out of love for Dart, this package is huge and consumes a lot of working time. Donate

Sound Dart.

This package tries to transpile the TypeScript code into a sound Dart code.
For example, Dart doesn't have the concept of method overload but TS does. To try to make it sound, we create a Record of the overloaded method and add callable properties for each overloaded version.
For example, the document.createElement can have different argument types in the TS version, in the transpilled Dart version you can use all versions:

  • document.createElement.$1(HTMLElementTagNameMap.div) which, by inference, will return a HTMLDivElement.
  • document.createElement.$2('<div>oi</div>') that will return a generic HTMLElement.

Before releasing an stable version is important to know how to generate the best Dart we can.
To better understand the transpiler, refer to the wiki section Typescript to Dart.

Repo structure

There are 3 packages in this repo:

  • Typings: where should reside the generated interop from NPM packages and other sources. It calls ts2dart in the process.
  • Ts2Dart: a console app that receives a list of .d.ts files and transpiles them to Dart. It calls the ts_ast in the process.
  • ts_ast: a nodejs app that analyzes a .d.ts and dump the analyzed info into a json file
Clone this wiki locally