GithubHelp home page GithubHelp logo

type-gen's People

Contributors

farism avatar thejustinwalsh avatar thinknathan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

farism

type-gen's Issues

Type Constants

Currently constants are marked as any and declared with let and after browsing the source they appear to be of either number or string mostly, as well as indeed const. The docs themselves do not directly inform if they are a number or a string constant, however it is not entirely important to type as they are exposed to lua from the C++ API.

In order to provide some additional TypeScript type safeness we could brand each constant per module so you do not use the wrong constant in the wrong namespace...

declare enum DefoldConstant { _ = "" }
declare let GENERIC_CONSTANT: DefoldConstant;

We could parse the docs for the use of the constant, and read the type from the call site, as so far it appears the constants at the call site are referred to as either a number i,e resource.set_texture(path,table,buffer), a constant i.e resource.store_manifest() a constant | vector i.e. go.animate().

declare enum DefoldResourceConstant { _ = "" }
declare type ResourceTextureConstant = DefoldResourceConstant | number & {
}

declare type ResourceLiveUpdateConstant = DefoldResourceConstant & {
}

In the case of go.animate() the types are not directly called out and we would need to rely on some pattern matching. The parameter is named easing it is a constant | vector and we have constants that start with the name EASING_...

declare enum DefoldGoConstant { _ = "" }
declare type GoEasingConstant = DefoldGoConstant | vmath.vector3 & {
}

export const EASING_INBACK: GoEasingConstant 

The parser may need to be extended to store some additional context so that the generator can run some generation against the function calls in the module to determine naming convention and type.

Alternatively, constants could just be declared as constants scoped to the namespace, and the callsite itself go be modified when a number, vector, or some other constant type is presented to take either a scoped constant like ResourceConstant | type.

Multi-line go.property(...) calls fail in HTML5

Defold has a problem parsing go.property calls that are spread across multiple lines.
See: defold/defold#3342

If we make a call to a function, with another function call nested in tstl, the result is a multi-line expansion. They do this for better sourceMap support as there can only be one error per line. In order to work around this limitation the printer would need to be overriden in the printExpressionList method here:
https://github.com/TypeScriptToLua/TypeScriptToLua/blob/master/src/LuaPrinter.ts#L744

Switch statements

When targeting 5.1 TypeScriptToLua currently doesn't support switch statements in Lua 5.1 (TypeScriptToLua/TypeScriptToLua#194). You are free to bump your target version but from my experience HTML5 seems to only work with Lua 5.1 as the target.

I would like to work on a PR for switch support in Lua 5.1, but have been told it is a hard problem to solve.

Types for Defold Extensions

Support type definitions for extensions.

  • Ideally these types would be opt-in in your .tsconfig file, and not automatically included.
  • Library names should match the pattern of the library include so that there are not additional steps in getting type definitions to function.

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.