Giter VIP home page Giter VIP logo

dts-converter's Introduction

TypeScript definition to Dart JS interop facade converter

About

Take TypeScript definition files (.d.ts) from DefinitelyTyped and create Dart JS interop facades with this script. Well, at least try to. It's tricky as hell. Zillions of edge cases. But at least you don't have to do everything yourself.

Disclaimer

So far, the converter has been tested on and optimized for the following javascript frameworks

While Dart Analyzer reports the resulting library as free of errors, nothing except what's needed by the demos has been tested. The library will only be lightly maintained. I don't have time for this :)

Installation

Requirements

  • Dart SDK 1.13 or greater on your path

Install

$> pub global activate --source git https://github.com/blockforest/dts-converter

Usage

Two modes are supported by the converter.

Mode 1: Create a full project package

This way, you create a package to be reused, committed to github, uploaded to pub.

$> mkdir fancy_package
$> cd fancy_package
$> dts_converter --source /path/to/sources --source-library Chart --create-project

Mode 2: Create an internal package

This way, you create a package inside of your existing Dart project.

$> cd fancy_existing_project
$> dts_converter --source /path/to/sources --source-library Chart

The newly generated internal package will be added to your root pubspec. If this doesn't make any sense, use Mode 1.

Command line arguments

# --source          The path (relative or absolute) to the Typescript .d.ts source file(s) to convert.
# --source-library  The name of the javascript library to convert.
# --target          The path (relative!) the generated Dart library will be written to (defaults to 'lib')
# --target-library  The name of the dart library to be generated (defaults to same name as defined in --target).
# --create-project  Create full dart project with pubspec and library file (optional)

Example

You can find a conversion result here https://github.com/blockforest/dts-converter/blob/master/test/chart-generated/chart/chart.d.dart It was generated from this source: https://github.com/blockforest/dts-converter/blob/master/test/chart/chart.d.ts

Try for yourself

  • Check out the git source of this project

  • Open Terminal

  • cd to the root of this project

    $> cd dts-converter $> dart bin/dts_converter.dart --source test/chart --target test/chart-generated --source-library Chart --target-library chart

  • Marvel at the result

Issues and bugs

Please file reports on the GitHub Issue Tracker.

Disclaimer

We're in beta!

Next Steps

dts-converter's People

Contributors

nilsdoehring avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.