Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7f25ee5
converting 'else if' statements to lua 'elseif' instead of nested ifs…
tomblind Oct 19, 2018
9399f10
Const enum support (#253)
DoctorGester Oct 19, 2018
34d3f4a
refactored try block to allow rethrow (#251)
tomblind Oct 19, 2018
abb9f07
Made LuaJIT use table.unpack for destructing assignments (#257)
Perryvw Oct 19, 2018
3054adb
Fixed JIT using table.unpack (#258)
lolleko Oct 20, 2018
bab8df3
Moved transpile switch to Lua 5.2 (#259)
lolleko Oct 20, 2018
c4cd099
Cleaned up ForOf code (#260)
Perryvw Oct 21, 2018
e0ca0a4
passing nil instead of _G as context for global functions when in ES …
tomblind Oct 25, 2018
dcb71a2
fixed logic for determining strict mode
tomblind Oct 25, 2018
a24d775
replaced hack-around when passing nil as a function context with a nu…
tomblind Oct 25, 2018
f9a7eb3
testing viability of wrapping context/no-context calls on assignment
tomblind Oct 26, 2018
90b7eb9
working on more function assignment situations
tomblind Oct 26, 2018
f6e094f
Fix error in module namespace enum exporting (#272)
zengjie Oct 26, 2018
10be963
fixed getting constructor signature and refactored things a bit
tomblind Oct 29, 2018
fa5dd9b
checking resolved signature when comparing function types passed as a…
tomblind Oct 29, 2018
85b9d3b
0.11.0
Perryvw Nov 7, 2018
ad5f2e3
Update CHANGELOG.md
Perryvw Nov 7, 2018
8001015
Luajit unpack fix (#273)
hazzard993 Nov 8, 2018
26fe357
Fixed constructor overloads (#275)
lolleko Nov 8, 2018
9eb5962
Lualib omit when unused (#280)
hazzard993 Nov 11, 2018
6c6af51
Fixed bug with default values for constructor parameters
Perryvw Nov 18, 2018
1aae661
0.11.1
Perryvw Nov 18, 2018
a24caa2
working on assignment checks for methods vs functions
tomblind Nov 19, 2018
7fb2cad
handling context in calls and decls
tomblind Nov 19, 2018
8c75ff0
refactoring and handling tuple destructuring
tomblind Nov 19, 2018
fec41f0
generalized tuple assignment checking
tomblind Nov 19, 2018
422e676
overloads with function and method signatures default to functions now
tomblind Nov 21, 2018
7731342
preventing non-methods from being passed to bind/call/apply
tomblind Nov 21, 2018
eca6cc2
removed uneccessary helpers
tomblind Nov 21, 2018
8314a1e
using proper exceptions for function conversion errors
tomblind Nov 21, 2018
abde08f
removed context arg from custom constructors and added check for assi…
tomblind Nov 22, 2018
07887a5
updated tests
tomblind Nov 22, 2018
4ac27f5
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Nov 22, 2018
5b10da7
Merge branch 'new-functions' into new-functions-assign-experiment
tomblind Nov 22, 2018
7170080
removing leftover NoContext decorators
tomblind Nov 23, 2018
6ac127b
Added discord badge and link to readme
Perryvw Nov 24, 2018
f90e2ec
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Nov 24, 2018
dbe201a
Added support for JSDoc tags as decorators
Perryvw Nov 25, 2018
daa1e67
Fixed invalid jsdoc failing a test
Perryvw Nov 25, 2018
35381a9
Added deprecation warning for ! decorators
Perryvw Nov 26, 2018
5586828
Refactored decorator creation, made decorators case-insensitive
Perryvw Nov 26, 2018
ea2942b
Fixed jsdoc tests
Perryvw Nov 27, 2018
dcae417
Fixed test runner not failing
Perryvw Nov 27, 2018
3ac149e
recursing into interfaces during assignment validation
tomblind Nov 28, 2018
b9838b0
Update README.md
Perryvw Nov 29, 2018
2913e93
fixes for issues with overloads using different context types
tomblind Nov 30, 2018
e088b7f
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Nov 30, 2018
3d994fa
Fixed casing and symbol of decorators to be consistent with the new c…
Perryvw Dec 1, 2018
ce74fe6
Feature/jsdoc annotations (#285)
Perryvw Dec 1, 2018
b79756e
less-lazy variable naming and improved error message
tomblind Dec 2, 2018
060f393
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Dec 2, 2018
ddc5a51
removing assignments translation test (#296)
tomblind Dec 2, 2018
6d5c032
Create CONTRIBUTING.md
Perryvw Dec 2, 2018
be2b164
Update README.md
Perryvw Dec 2, 2018
a4f1f56
Detecting types derived from array (#289)
TheLartians Dec 2, 2018
f5ed657
0.12.0
Perryvw Dec 4, 2018
0b8e485
stabilize package lock
Perryvw Dec 4, 2018
d6c7a0d
Check inherited accessors (#297)
TheLartians Dec 7, 2018
fc41aa3
Fixed default constructor on subclass (#301)
yancouto Dec 9, 2018
c0b73bd
Use declared types (#302)
TheLartians Dec 9, 2018
a61f841
0.12.1
Perryvw Dec 10, 2018
055060a
suite of tests for new functions and fixes for edge-cases found
tomblind Dec 11, 2018
7fda8ac
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Dec 12, 2018
53f35e6
validating return values and hanlding inference of contexts when pass…
tomblind Dec 13, 2018
72d0edc
renamed getFunctionReturnType to getContainingFunctionReturnType
tomblind Dec 14, 2018
213ba03
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Dec 14, 2018
b4b0820
handling more edge cases, adding more tests and a little bit of refac…
tomblind Dec 14, 2018
6f53190
Merge remote-tracking branch 'upstream/new-functions' into new-functions
tomblind Dec 15, 2018
04ca8eb
Merge branch 'master' into new-functions
tomblind Dec 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 0.11.0
* Fixed bug when throwing anything that was not a string. (@tomblind)
* Added support for object literal method declarations. (@tomblind)
* Fixed several issues with assignment operators (@tomblind)
* `else if` statements are now transpiled to Lua `elseif` instead of nested ifs statements. (@tomblind)
* Occurrences of const enum values are now directly replaced with their value in the Lua output. (@DoctorGester)
* Rethrowing is now possible from try/catch blocks (@tomblind)
* Destructing statements in LuaJit now use `unpack` instead of `table.unpack`
* Removed support for switch statements for versions <= 5.1.
* Refactored `for ... of` translation, it now uses numeric `for ` loops instead of `ipairs` for performance reasons.

## 0.10.0
* Added support for NonNullExpression (`abc!` transforming the type from `abc | undefined` to `abc`)
* Added expression position to replacement binary expression to improve error messages.
* Fixed various issues with !TupleReturn (@tomblind)
* Added support for `array.reverse`, `array.shift`, `array.unshift`, `array.sort`. (@andreiradu)
* Added translation for `Object.hasOwnProperty()`. (@andreiradu)
* Added support for class expressions (@andreiradu)
* Fixed bug in detecting array types (@tomblind)
* Added public API functions and better webpack functionality.

## 0.9.0
* Fixed an issue where default parameter values were ignored in function declarations.
* Fixed a bug where `self` was undefined in function properties.
Expand Down
80 changes: 80 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing to TypeScriptToLua

1) [Project Overview](#project-overview)
2) [Running Tests](#running-tests)
3) [Testing Guidelines](#testing-guidelines)
4) [Coding Conventions](#coding-conventions)

## Project Overview
To get familiar with the project structure, here is a short overview of each directory and their function.
- `src/`
* Source code for the project, has the transpiler core files in its root.
* `src/lualib/`
- Contains the TypeScript source for the lualib. This consists of implementations of standard TypeScript functions that are not present in Lua. These files are compiled to Lua using the transpiler. They are included in the Lua result when transpiling.
* `src/targets/`
- Version-specific transpiler overrides for the different Lua targets. The main transpiler transpiles Lua 5.0, each target-specific transpiler extends the transpiler of the version before it, so the 5.3 inherits 5.2 which inherits 5.1 which inherits 5.0. LuaJIT is based on 5.2 so inherits from the 5.2 transpiler.
* *Compiler.ts* - Main entry point of the transpiler, this is what interfaces with the TypeScript compiler API.
* *Transpiler.ts* - Main transpiler code, transforms a TypeScript AST to a Lua string.
* *TSHelper.ts* - Helper methods used during the transpilation process.
- `test/`
* This directory contains all testing code for the transpiler.
* `test/src/`
- Contains all extra source and utility used to run tests.
* `test/unit/`
- Unit/Functional tests for the transpiler. Tests in here are grouped by functionality they are testing. Generally each of these tests uses the transpiler to transpile some TypeScript to Lua, then executes it using the Fengari Lua VM. Assertion is done on the result of the lua code.
* `test/translation/`
- **[Obsolete]** Contains tests that only check the transpiled Lua String. We prefer adding unit/functional tests over translation tests. This directory will probably be removed at some point.

## Running Tests
The tests for this project can be executed using the standard `npm test`. This runs all tests (can take a while!).

### Testing while developing
Due to the time required to run all tests, it is impractical to run every test while developing part of the transpiler. To speed up the test run you can import `FocusTest` or `FocusTests` from Alsatian. If a class is decorated with `@FocusTests`, all other test classes will be ignored. Similarly, if any test method is decorated with `@FocusTest`, only `@FocusTest` methods will be run during `npm test`.

For example:
```ts
import { Expect, FocusTests, Test, TestCase } from "alsatian";

@FocusTests
export class FunctionTests {
// All tests in here will be executed.
}

// All other tests will be ignored.
```

Or

```ts
import { Expect, FocusTest, Test, TestCase } from "alsatian";

export class FunctionTests {
@FocusTest
@Test("Example test 1")
public test1(): void { // Will be executed
}

@FocusTest
@Test("Example test 2")
public test2(): void { // Will also be executed
}

@Test("Example test 3")
public test3(): void { // Will be ignored
}
}

// All other tests will be ignored.
```


## Testing Guidelines
When submitting a pull request with new functionality, we require some functional (transpile and execute Lua) to be added, to ensure the new functionality works as expected, and will continue to work that way.

Translation tests are discouraged as in most cases as we do not really care about the exact Lua output, as long as executing it results in the correct result (which is tested by functional tests).

## Coding Conventions
Most coding conventions are enforced by the ts-lint configuration. The test process will fail if code does not pass the linter. Some extra conventions worth mentioning:
* Do not abbreviate variable names. The exception here are inline lambda arguments, if it is obvious what the argument is you can abbreviate to the first letter, e.g: `statements.filter(s => ts.VariableStatement(s))`
* Readability of code is more important than the amount of space it takes. If extra line breaks make your code more readable, add them.
* Functional style is encouraged!
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Large projects written in lua can become hard to maintain and make it easy to ma
[![Build Status](https://travis-ci.org/Perryvw/TypescriptToLua.svg?branch=master)](https://travis-ci.org/Perryvw/TypescriptToLua)
[![Build status](https://ci.appveyor.com/api/projects/status/github/perryvw/typescripttolua?branch=master&svg=true)](https://ci.appveyor.com/project/Perryvw/typescripttolua)
[![Coverage](https://codecov.io/gh/perryvw/typescripttolua/branch/master/graph/badge.svg)](https://codecov.io/gh/perryvw/typescripttolua)
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/TypescriptToLua/Lobby)

You can chat with us on Discord: [![Discord](https://img.shields.io/discord/515854149821267971.svg)](https://discord.gg/BWAq58Y)

## Documentation
More detailed documentation and info on writing declarations can be found [on the wiki](https://github.com/Perryvw/TypescriptToLua/wiki).
Expand Down Expand Up @@ -40,6 +41,9 @@ Changelog can be found in [CHANGELOG.md](https://github.com/Perryvw/TypescriptTo
}
```

## Contributing
All contributions are welcome, but please read our [contribution guidelines](https://github.com/Perryvw/TypescriptToLua/blob/master/CONTRIBUTING.md)!

## Declarations
The real power of this transpiler is usage together with good declarations for the Lua API provided. Some examples of Lua interface declarations can be found here:
- [Dota 2 Modding](https://github.com/ModDota/API/tree/master/declarations/server)
Expand Down
Loading