Giter Club home page Giter Club logo

ts2hx's Introduction

ts2hx's People

Contributors

frabbit avatar jdonaldson avatar kevinresol avatar nadako avatar ncannasse avatar simn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ts2hx's Issues

support tuples

right now, TS tuples are generated as Array<Dynamic> which is what they actually are at runtime, but I suppose we should have a typed abstract over that to properly map typescript declaration.

haxe build.hxml errors

Can't build it

/usr/lib/haxe/lib/hxargs/3,0,0/hxargs/Args.hx:91: characters 43-61 : Null<haxe.macro.Expr> has no field getValue
src/tshx/Converter.hx:87: characters 64-71 : Array<{ sub : Null<String>, params : Array<haxe.macro.TypeParam>, pack : Array<String>, name : String }> should be haxe.macro.TypePath
src/tshx/Converter.hx:87: characters 64-71 : Array<{ sub : Null<String>, params : Array<haxe.macro.TypeParam>, pack : Array<String>, name : String }> should be { ?sub : Null<String>, ?params : Array<haxe.macro.TypeParam>, pack : Array<String>, name : String }
src/tshx/Converter.hx:87: characters 64-71 : Array<{ sub : Null<String>, params : Array<haxe.macro.TypeParam>, pack : Array<String>, name : String }> has no field name
src/tshx/Converter.hx:87: characters 64-71 : For function argument 'p'

Haxe 3.1, should I get nighty?

Libs from haxelib

  • hxparse
  • hxargs

Cannot type an imported member referenced by `typeof`

This is both a ts2hx and a haxe issue:

I've generated some definition from rxjs (-d option of tsc compiler)
and I see that this library expand functionality of Observable by enhancing it's definition in file scope when someone does some imports of declaration that looks like this:

declare module "add/operator/expand" {
    import { expand } from "operator/expand";
    module "Observable" {
        interface Observable<T> {
            expand: typeof expand;
        }
    }
}

This one add the expand member to Observable with the type referenced from the import.

If we want to translate that to haxe via ts2hx (with some minor tweaks to it since it was not able to parse some typescript features), then we have the problem of defining a type based on another one.

I'm refering here to the type of the expand member which would take the type of the imported expandthing (which is actually 3 functions).

Do you think that's something that may evolve?

Readme does not list TS libraries tested/used against with dates. +...

I was just thinking that the Readme does not list TS libraries tested/used against, users should be encouraged to submit these with notes? By creating a list of libraries it shows feasibility and helps resolve a few objections raised against Haxe.

I was wondering if there are TS libraries currently "limited" to js target that would be worth platform generalizing, this project could maybe create stub files for more general Haxe ports or possible full transpiling. My thought is that any progress in this direction will really start to show Haxe as the better flexible solution. Imagine taking webgl TS libs and luxe-ing them, when you consider nodejs wrapper file sizes tend to be rather excessive ( node-webkit a whole browser bundled with you app, which is heavy! ), users will suddenly realize they need a Haxe solution for thier typescript project when targeting mobile.

How do I build this?

When I do haxe build.hxml I see run.n get spit out, running neko run.n then creates out directory, but it is empty. haxe build.hxml goes through without any stdout messages, so does neko run.n. I was expecting to see ts2hx.n in out which I'd then run using neko ts2hx.n --rec…

neko

NekoVM 2.1.0 (c)2005-2016 Haxe Foundation
  Usage : neko <file>

haxe -v

3.2.1

Doing neko run.n --help gives what the README says it should. Doing neko run "input" --recur… does seemingly nothing.

Error when running neko ts2hx.n --recursive: NoMatch TIdent($)

I installed ts2hx and the current version of DefinitelyTyped. I get the following error, when running neko ts2hx.n --recursive:

Called from ? line 1
Called from Main.hx line 60
Called from Main.hx line 118
Called from Main.hx line 105
Called from Main.hx line 105
Called from Main.hx line 110
Called from Main.hx line 70
Uncaught exception - zepto-tes:line 3:characters 1-2: NoMatch TIdent($)

Uncaught exception - Invalid field access : length

I tried converting the entirety of the DefinitelyTyped repo, but many definitions failed with the following exception:

Called from ? line 1
Called from Main.hx line 69
Called from Main.hx line 111
Called from Main.hx line 87
Called from Main.hx line 101
Called from Main.hx line 92
Called from Main.hx line 154
Called from E:\Apps\Programming\HaxeToolkit\haxe\std/haxe/macro/Printer.hx line
251
Uncaught exception - Invalid field access : length

Here is one of the simplest definitions I could find:
https://github.com/borisyankov/DefinitelyTyped/blob/master/add2home/add2home.d.ts
This is nothing more than a variable declaration, containing an object with three functions.

Another example:
https://github.com/borisyankov/DefinitelyTyped/blob/master/accounting/accounting.d.ts
This defines a variable "accounting", which then gets exported in a module.

Another example:
https://github.com/borisyankov/DefinitelyTyped/blob/master/alertify/alertify.d.ts
This defines a variable, "declare var alertify: alertify.IAlertifyStatic;", and a module. The module seems to get transpiled & written correctly, but an error is also thrown, presumably because of the variable declaration. As an experiment, I removed the variable declaration line, and then no error was thrown (though I don't know if the output was entirely correct, since it would be missing the var decl conversion).

Full output log is here:
https://gist.github.com/laurence-myers/e865cae0a1c126c49337

support callable objects

TypeScript supports callable objects with multiple signatures. We could support this with the new @:selfCall metadata. So, we define a new method by some convention (how do we avoid potential name clashes?) adding all signatures as @:overload and append @:selfCall to it.

Also there are cases like this one: https://github.com/borisyankov/DefinitelyTyped/blob/1d08e36fe3ce81715cb956223f7e5a0a9882cd63/node/node.d.ts#L1341, maybe we should translate that var into an overloaded function.

generate consistent module + package structure

ts2hx should generate a consistent and useful package/module structure similar to what's implemented in hxnodejs (and discussed in HaxeFoundation/hxnodejs#16 before).

basically that means the following:

  • a module becomes static class with capitalized name (and underscore changed to CamelCase)
  • types defined in the module go into a subpackage named after the original module

for example, node's "fs" module become Fs.hx, and "fs.Stats" goes to fs/Stats.hx

NoMatch TAssign

Attempt to use on Cats IDE written in TypeScript
https://github.com/jbaron/cats

Main.hx:93: Written out/lib/Intl.hx
Main.hx:93: Written out/lib/toplevel.hx
Called from ? line 1
Called from Main.hx line 60
Called from Main.hx line 118
Called from Main.hx line 105
Called from Main.hx line 105
Called from Main.hx line 110
Called from Main.hx line 70
Uncaught exception - local_requi:line 2:characters 10-11: NoMatch TAssign

keyword variables

TypeScript apparently allows to use keywords as a variable/function name (e.g. declare var class). We should handle haxe keywords somehow. I'm not sure whether @:native is enough for that (e.g. @:native("class") var class_:Dynamic;) or we should generate a property with inline getters/setters (e.g. var class_(get,set):Dynamic; inline function get_class_():Dynamic return untyped this["class"];)

Doesn't work with latest hxparse

Hi,
ts2hx doesn't work with latest hxparse.
It fails with 'src/tshx/Parser.hx:6: lines 6-437 : Class not found : hxparse.LexerTokenSource'

Any suggestions how can I ts2hx make it work?

Thanks in advance,
Dinko

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.