diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aeb1a386..d5653a64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..13f2db018 --- /dev/null +++ b/CONTRIBUTING.md @@ -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! diff --git a/README.md b/README.md index 852dae602..307f56dae 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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) diff --git a/package-lock.json b/package-lock.json index 245ff34a6..45593c4c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "typescript-to-lua", - "version": "0.10.0", + "version": "0.12.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -16,9 +16,9 @@ "integrity": "sha512-wc+VveszMLyMWFvXLkloixT4n0harUIVZjnpzztaZ0nKLuul7Z32iMt2fUFGAaZ4y1XWjFRMtCI5ewvyh4aIeg==", "dev": true, "requires": { - "@types/events": "*", - "@types/minimatch": "*", - "@types/node": "*" + "@types/events": "1.2.0", + "@types/minimatch": "3.0.3", + "@types/node": "9.6.23" } }, "@types/minimatch": { @@ -45,10 +45,10 @@ "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "co": "4.6.0", + "fast-deep-equal": "1.1.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" } }, "alsatian": { @@ -57,10 +57,10 @@ "integrity": "sha1-B+qeiU7bnqmX7VcaZOFMyYsj0/g=", "dev": true, "requires": { - "@types/node": ">=4.0.0", - "extendo-error": "^1.0.1", - "glob": "^7.0.3", - "reflect-metadata": "^0.1.3", + "@types/node": "9.6.23", + "extendo-error": "1.0.1", + "glob": "7.1.2", + "reflect-metadata": "0.1.12", "tap-bark": "1.0.0" } }, @@ -81,7 +81,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "sprintf-js": "1.0.3" } }, "argv": { @@ -132,9 +132,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" } }, "balanced-match": { @@ -150,7 +150,7 @@ "dev": true, "optional": true, "requires": { - "tweetnacl": "^0.14.3" + "tweetnacl": "0.14.5" } }, "brace-expansion": { @@ -159,7 +159,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -192,11 +192,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, "circular-json": { @@ -210,9 +210,9 @@ "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "wrap-ansi": "2.1.0" }, "dependencies": { "ansi-regex": { @@ -225,7 +225,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -248,7 +248,7 @@ "dev": true, "requires": { "argv": "0.0.2", - "request": "^2.81.0", + "request": "2.87.0", "urlgrey": "0.4.4" } }, @@ -273,7 +273,7 @@ "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "dev": true, "requires": { - "delayed-stream": "~1.0.0" + "delayed-stream": "1.0.0" } }, "commander": { @@ -299,9 +299,9 @@ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "lru-cache": "4.1.3", + "shebang-command": "1.2.0", + "which": "1.3.1" } }, "dashdash": { @@ -310,7 +310,7 @@ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" } }, "decamelize": { @@ -352,7 +352,7 @@ "dev": true, "optional": true, "requires": { - "jsbn": "~0.1.0" + "jsbn": "0.1.1" } }, "escape-string-regexp": { @@ -390,13 +390,13 @@ "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" } }, "extend": { @@ -435,9 +435,9 @@ "integrity": "sha512-NleQtQymPtbjBPnGOQiXfZfKpP3R7si+Sbkke631PWNnZt86eZSlymRJ0qv/KUTcz0fSsWO1iltZYz5/JV1uYQ==", "dev": true, "requires": { - "readline-sync": "^1.4.9", - "sprintf-js": "^1.1.1", - "tmp": "^0.0.33" + "readline-sync": "1.4.9", + "sprintf-js": "1.1.1", + "tmp": "0.0.33" }, "dependencies": { "sprintf-js": { @@ -453,7 +453,7 @@ "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "requires": { - "locate-path": "^3.0.0" + "locate-path": "3.0.0" } }, "forever-agent": { @@ -468,9 +468,9 @@ "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "dev": true, "requires": { - "asynckit": "^0.4.0", + "asynckit": "0.4.0", "combined-stream": "1.0.6", - "mime-types": "^2.1.12" + "mime-types": "2.1.18" } }, "fs.realpath": { @@ -495,7 +495,7 @@ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "dev": true, "requires": { - "assert-plus": "^1.0.0" + "assert-plus": "1.0.0" } }, "glob": { @@ -504,12 +504,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "har-schema": { @@ -524,8 +524,8 @@ "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "dev": true, "requires": { - "ajv": "^5.1.0", - "har-schema": "^2.0.0" + "ajv": "5.5.2", + "har-schema": "2.0.0" } }, "has-ansi": { @@ -534,7 +534,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "has-flag": { @@ -549,9 +549,9 @@ "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "dev": true, "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "assert-plus": "1.0.0", + "jsprim": "1.4.1", + "sshpk": "1.14.2" } }, "inflight": { @@ -560,8 +560,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -620,8 +620,8 @@ "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.10", + "esprima": "4.0.0" } }, "jsbn": { @@ -666,7 +666,7 @@ "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", "requires": { - "invert-kv": "^1.0.0" + "invert-kv": "1.0.0" } }, "locate-path": { @@ -674,8 +674,8 @@ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "3.0.0", + "path-exists": "3.0.0" } }, "lru-cache": { @@ -683,8 +683,8 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "pseudomap": "1.0.2", + "yallist": "2.1.2" } }, "make-error": { @@ -698,7 +698,7 @@ "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", "requires": { - "mimic-fn": "^1.0.0" + "mimic-fn": "1.2.0" } }, "mime-db": { @@ -713,7 +713,7 @@ "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { - "mime-db": "~1.33.0" + "mime-db": "1.33.0" } }, "mimic-fn": { @@ -727,7 +727,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -764,7 +764,7 @@ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", "requires": { - "path-key": "^2.0.0" + "path-key": "2.0.1" } }, "number-is-nan": { @@ -778,33 +778,33 @@ "integrity": "sha512-w8OdJAhXL5izerzZMdqzYKMj/pgHJyY3qEPYBjLLxrhcVoHEY9pU5ENIiZyCgG9OR7x3VcUMoD40o6PtVpfR4g==", "dev": true, "requires": { - "archy": "^1.0.0", - "arrify": "^1.0.1", - "caching-transform": "^1.0.0", - "convert-source-map": "^1.5.1", - "debug-log": "^1.0.1", - "default-require-extensions": "^1.0.0", - "find-cache-dir": "^0.1.1", - "find-up": "^2.1.0", - "foreground-child": "^1.5.3", - "glob": "^7.0.6", - "istanbul-lib-coverage": "^1.1.2", - "istanbul-lib-hook": "^1.1.0", - "istanbul-lib-instrument": "^1.10.0", - "istanbul-lib-report": "^1.1.3", - "istanbul-lib-source-maps": "^1.2.3", - "istanbul-reports": "^1.4.0", - "md5-hex": "^1.2.0", - "merge-source-map": "^1.1.0", - "micromatch": "^3.1.10", - "mkdirp": "^0.5.0", - "resolve-from": "^2.0.0", - "rimraf": "^2.6.2", - "signal-exit": "^3.0.1", - "spawn-wrap": "^1.4.2", - "test-exclude": "^4.2.0", + "archy": "1.0.0", + "arrify": "1.0.1", + "caching-transform": "1.0.1", + "convert-source-map": "1.5.1", + "debug-log": "1.0.1", + "default-require-extensions": "1.0.0", + "find-cache-dir": "0.1.1", + "find-up": "2.1.0", + "foreground-child": "1.5.6", + "glob": "7.1.2", + "istanbul-lib-coverage": "1.2.0", + "istanbul-lib-hook": "1.1.0", + "istanbul-lib-instrument": "1.10.1", + "istanbul-lib-report": "1.1.3", + "istanbul-lib-source-maps": "1.2.3", + "istanbul-reports": "1.4.0", + "md5-hex": "1.3.0", + "merge-source-map": "1.1.0", + "micromatch": "3.1.10", + "mkdirp": "0.5.1", + "resolve-from": "2.0.0", + "rimraf": "2.6.2", + "signal-exit": "3.0.2", + "spawn-wrap": "1.4.2", + "test-exclude": "4.2.1", "yargs": "11.1.0", - "yargs-parser": "^8.0.0" + "yargs-parser": "8.1.0" }, "dependencies": { "align-text": { @@ -812,9 +812,9 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" } }, "amdefine": { @@ -837,7 +837,7 @@ "bundled": true, "dev": true, "requires": { - "default-require-extensions": "^1.0.0" + "default-require-extensions": "1.0.0" } }, "archy": { @@ -890,9 +890,9 @@ "bundled": true, "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" } }, "babel-generator": { @@ -900,14 +900,14 @@ "bundled": true, "dev": true, "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "detect-indent": "4.0.0", + "jsesc": "1.3.0", + "lodash": "4.17.10", + "source-map": "0.5.7", + "trim-right": "1.0.1" } }, "babel-messages": { @@ -915,7 +915,7 @@ "bundled": true, "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "babel-runtime": "6.26.0" } }, "babel-runtime": { @@ -923,8 +923,8 @@ "bundled": true, "dev": true, "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" + "core-js": "2.5.6", + "regenerator-runtime": "0.11.1" } }, "babel-template": { @@ -932,11 +932,11 @@ "bundled": true, "dev": true, "requires": { - "babel-runtime": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "lodash": "^4.17.4" + "babel-runtime": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "lodash": "4.17.10" } }, "babel-traverse": { @@ -944,15 +944,15 @@ "bundled": true, "dev": true, "requires": { - "babel-code-frame": "^6.26.0", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" + "babel-code-frame": "6.26.0", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "debug": "2.6.9", + "globals": "9.18.0", + "invariant": "2.2.4", + "lodash": "4.17.10" } }, "babel-types": { @@ -960,10 +960,10 @@ "bundled": true, "dev": true, "requires": { - "babel-runtime": "^6.26.0", - "esutils": "^2.0.2", - "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" + "babel-runtime": "6.26.0", + "esutils": "2.0.2", + "lodash": "4.17.10", + "to-fast-properties": "1.0.3" } }, "babylon": { @@ -981,13 +981,13 @@ "bundled": true, "dev": true, "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" + "cache-base": "1.0.1", + "class-utils": "0.3.6", + "component-emitter": "1.2.1", + "define-property": "1.0.0", + "isobject": "3.0.1", + "mixin-deep": "1.3.1", + "pascalcase": "0.1.1" }, "dependencies": { "define-property": { @@ -995,7 +995,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "is-accessor-descriptor": { @@ -1003,7 +1003,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -1011,7 +1011,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -1019,9 +1019,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" } }, "isobject": { @@ -1041,7 +1041,7 @@ "bundled": true, "dev": true, "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -1050,16 +1050,16 @@ "bundled": true, "dev": true, "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" + "arr-flatten": "1.1.0", + "array-unique": "0.3.2", + "extend-shallow": "2.0.1", + "fill-range": "4.0.0", + "isobject": "3.0.1", + "repeat-element": "1.1.2", + "snapdragon": "0.8.2", + "snapdragon-node": "2.1.1", + "split-string": "3.1.0", + "to-regex": "3.0.2" }, "dependencies": { "extend-shallow": { @@ -1067,7 +1067,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -1082,15 +1082,15 @@ "bundled": true, "dev": true, "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" + "collection-visit": "1.0.0", + "component-emitter": "1.2.1", + "get-value": "2.0.6", + "has-value": "1.0.0", + "isobject": "3.0.1", + "set-value": "2.0.0", + "to-object-path": "0.3.0", + "union-value": "1.0.0", + "unset-value": "1.0.0" }, "dependencies": { "isobject": { @@ -1105,9 +1105,9 @@ "bundled": true, "dev": true, "requires": { - "md5-hex": "^1.2.0", - "mkdirp": "^0.5.1", - "write-file-atomic": "^1.1.4" + "md5-hex": "1.3.0", + "mkdirp": "0.5.1", + "write-file-atomic": "1.3.4" } }, "camelcase": { @@ -1122,8 +1122,8 @@ "dev": true, "optional": true, "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" + "align-text": "0.1.4", + "lazy-cache": "1.0.4" } }, "chalk": { @@ -1131,11 +1131,11 @@ "bundled": true, "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, "class-utils": { @@ -1143,10 +1143,10 @@ "bundled": true, "dev": true, "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" + "arr-union": "3.1.0", + "define-property": "0.2.5", + "isobject": "3.0.1", + "static-extend": "0.1.2" }, "dependencies": { "define-property": { @@ -1154,7 +1154,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "isobject": { @@ -1170,8 +1170,8 @@ "dev": true, "optional": true, "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", + "center-align": "0.1.3", + "right-align": "0.1.3", "wordwrap": "0.0.2" }, "dependencies": { @@ -1193,8 +1193,8 @@ "bundled": true, "dev": true, "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" + "map-visit": "1.0.0", + "object-visit": "1.0.1" } }, "commondir": { @@ -1232,8 +1232,8 @@ "bundled": true, "dev": true, "requires": { - "lru-cache": "^4.0.1", - "which": "^1.2.9" + "lru-cache": "4.1.3", + "which": "1.3.0" } }, "debug": { @@ -1264,7 +1264,7 @@ "bundled": true, "dev": true, "requires": { - "strip-bom": "^2.0.0" + "strip-bom": "2.0.0" } }, "define-property": { @@ -1272,8 +1272,8 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" + "is-descriptor": "1.0.2", + "isobject": "3.0.1" }, "dependencies": { "is-accessor-descriptor": { @@ -1281,7 +1281,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -1289,7 +1289,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -1297,9 +1297,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" } }, "isobject": { @@ -1319,7 +1319,7 @@ "bundled": true, "dev": true, "requires": { - "repeating": "^2.0.0" + "repeating": "2.0.1" } }, "error-ex": { @@ -1327,7 +1327,7 @@ "bundled": true, "dev": true, "requires": { - "is-arrayish": "^0.2.1" + "is-arrayish": "0.2.1" } }, "escape-string-regexp": { @@ -1345,13 +1345,13 @@ "bundled": true, "dev": true, "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" }, "dependencies": { "cross-spawn": { @@ -1359,9 +1359,9 @@ "bundled": true, "dev": true, "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" + "lru-cache": "4.1.3", + "shebang-command": "1.2.0", + "which": "1.3.0" } } } @@ -1371,13 +1371,13 @@ "bundled": true, "dev": true, "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "posix-character-classes": "0.1.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" }, "dependencies": { "define-property": { @@ -1385,7 +1385,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "extend-shallow": { @@ -1393,7 +1393,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -1403,8 +1403,8 @@ "bundled": true, "dev": true, "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" }, "dependencies": { "is-extendable": { @@ -1412,7 +1412,7 @@ "bundled": true, "dev": true, "requires": { - "is-plain-object": "^2.0.4" + "is-plain-object": "2.0.4" } } } @@ -1422,14 +1422,14 @@ "bundled": true, "dev": true, "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "array-unique": "0.3.2", + "define-property": "1.0.0", + "expand-brackets": "2.1.4", + "extend-shallow": "2.0.1", + "fragment-cache": "0.2.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" }, "dependencies": { "define-property": { @@ -1437,7 +1437,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "extend-shallow": { @@ -1445,7 +1445,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } }, "is-accessor-descriptor": { @@ -1453,7 +1453,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -1461,7 +1461,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -1469,9 +1469,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" } }, "kind-of": { @@ -1486,10 +1486,10 @@ "bundled": true, "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" + "extend-shallow": "2.0.1", + "is-number": "3.0.0", + "repeat-string": "1.6.1", + "to-regex-range": "2.1.1" }, "dependencies": { "extend-shallow": { @@ -1497,7 +1497,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -1507,9 +1507,9 @@ "bundled": true, "dev": true, "requires": { - "commondir": "^1.0.1", - "mkdirp": "^0.5.1", - "pkg-dir": "^1.0.0" + "commondir": "1.0.1", + "mkdirp": "0.5.1", + "pkg-dir": "1.0.0" } }, "find-up": { @@ -1517,7 +1517,7 @@ "bundled": true, "dev": true, "requires": { - "locate-path": "^2.0.0" + "locate-path": "2.0.0" } }, "for-in": { @@ -1530,8 +1530,8 @@ "bundled": true, "dev": true, "requires": { - "cross-spawn": "^4", - "signal-exit": "^3.0.0" + "cross-spawn": "4.0.2", + "signal-exit": "3.0.2" } }, "fragment-cache": { @@ -1539,7 +1539,7 @@ "bundled": true, "dev": true, "requires": { - "map-cache": "^0.2.2" + "map-cache": "0.2.2" } }, "fs.realpath": { @@ -1567,12 +1567,12 @@ "bundled": true, "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "globals": { @@ -1590,10 +1590,10 @@ "bundled": true, "dev": true, "requires": { - "async": "^1.4.0", - "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" }, "dependencies": { "source-map": { @@ -1601,7 +1601,7 @@ "bundled": true, "dev": true, "requires": { - "amdefine": ">=0.0.4" + "amdefine": "1.0.1" } } } @@ -1611,7 +1611,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "has-flag": { @@ -1624,9 +1624,9 @@ "bundled": true, "dev": true, "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" + "get-value": "2.0.6", + "has-values": "1.0.0", + "isobject": "3.0.1" }, "dependencies": { "isobject": { @@ -1641,8 +1641,8 @@ "bundled": true, "dev": true, "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" + "is-number": "3.0.0", + "kind-of": "4.0.0" }, "dependencies": { "is-number": { @@ -1650,7 +1650,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -1658,7 +1658,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -1668,7 +1668,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -1688,8 +1688,8 @@ "bundled": true, "dev": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -1702,7 +1702,7 @@ "bundled": true, "dev": true, "requires": { - "loose-envify": "^1.0.0" + "loose-envify": "1.3.1" } }, "invert-kv": { @@ -1715,7 +1715,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" } }, "is-arrayish": { @@ -1733,7 +1733,7 @@ "bundled": true, "dev": true, "requires": { - "builtin-modules": "^1.0.0" + "builtin-modules": "1.1.1" } }, "is-data-descriptor": { @@ -1741,7 +1741,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" } }, "is-descriptor": { @@ -1749,9 +1749,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" }, "dependencies": { "kind-of": { @@ -1771,7 +1771,7 @@ "bundled": true, "dev": true, "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "is-fullwidth-code-point": { @@ -1784,7 +1784,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" } }, "is-odd": { @@ -1792,7 +1792,7 @@ "bundled": true, "dev": true, "requires": { - "is-number": "^4.0.0" + "is-number": "4.0.0" }, "dependencies": { "is-number": { @@ -1807,7 +1807,7 @@ "bundled": true, "dev": true, "requires": { - "isobject": "^3.0.1" + "isobject": "3.0.1" }, "dependencies": { "isobject": { @@ -1857,7 +1857,7 @@ "bundled": true, "dev": true, "requires": { - "append-transform": "^0.4.0" + "append-transform": "0.4.0" } }, "istanbul-lib-instrument": { @@ -1865,13 +1865,13 @@ "bundled": true, "dev": true, "requires": { - "babel-generator": "^6.18.0", - "babel-template": "^6.16.0", - "babel-traverse": "^6.18.0", - "babel-types": "^6.18.0", - "babylon": "^6.18.0", - "istanbul-lib-coverage": "^1.2.0", - "semver": "^5.3.0" + "babel-generator": "6.26.1", + "babel-template": "6.26.0", + "babel-traverse": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "istanbul-lib-coverage": "1.2.0", + "semver": "5.5.0" } }, "istanbul-lib-report": { @@ -1879,10 +1879,10 @@ "bundled": true, "dev": true, "requires": { - "istanbul-lib-coverage": "^1.1.2", - "mkdirp": "^0.5.1", - "path-parse": "^1.0.5", - "supports-color": "^3.1.2" + "istanbul-lib-coverage": "1.2.0", + "mkdirp": "0.5.1", + "path-parse": "1.0.5", + "supports-color": "3.2.3" }, "dependencies": { "supports-color": { @@ -1890,7 +1890,7 @@ "bundled": true, "dev": true, "requires": { - "has-flag": "^1.0.0" + "has-flag": "1.0.0" } } } @@ -1900,11 +1900,11 @@ "bundled": true, "dev": true, "requires": { - "debug": "^3.1.0", - "istanbul-lib-coverage": "^1.1.2", - "mkdirp": "^0.5.1", - "rimraf": "^2.6.1", - "source-map": "^0.5.3" + "debug": "3.1.0", + "istanbul-lib-coverage": "1.2.0", + "mkdirp": "0.5.1", + "rimraf": "2.6.2", + "source-map": "0.5.7" }, "dependencies": { "debug": { @@ -1922,7 +1922,7 @@ "bundled": true, "dev": true, "requires": { - "handlebars": "^4.0.3" + "handlebars": "4.0.11" } }, "js-tokens": { @@ -1940,7 +1940,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } }, "lazy-cache": { @@ -1954,7 +1954,7 @@ "bundled": true, "dev": true, "requires": { - "invert-kv": "^1.0.0" + "invert-kv": "1.0.0" } }, "load-json-file": { @@ -1962,11 +1962,11 @@ "bundled": true, "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "strip-bom": "2.0.0" } }, "locate-path": { @@ -1974,8 +1974,8 @@ "bundled": true, "dev": true, "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "p-locate": "2.0.0", + "path-exists": "3.0.0" }, "dependencies": { "path-exists": { @@ -2000,7 +2000,7 @@ "bundled": true, "dev": true, "requires": { - "js-tokens": "^3.0.0" + "js-tokens": "3.0.2" } }, "lru-cache": { @@ -2008,8 +2008,8 @@ "bundled": true, "dev": true, "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "pseudomap": "1.0.2", + "yallist": "2.1.2" } }, "map-cache": { @@ -2022,7 +2022,7 @@ "bundled": true, "dev": true, "requires": { - "object-visit": "^1.0.0" + "object-visit": "1.0.1" } }, "md5-hex": { @@ -2030,7 +2030,7 @@ "bundled": true, "dev": true, "requires": { - "md5-o-matic": "^0.1.1" + "md5-o-matic": "0.1.1" } }, "md5-o-matic": { @@ -2043,7 +2043,7 @@ "bundled": true, "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "mimic-fn": "1.2.0" } }, "merge-source-map": { @@ -2051,7 +2051,7 @@ "bundled": true, "dev": true, "requires": { - "source-map": "^0.6.1" + "source-map": "0.6.1" }, "dependencies": { "source-map": { @@ -2066,19 +2066,19 @@ "bundled": true, "dev": true, "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "braces": "2.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "extglob": "2.0.4", + "fragment-cache": "0.2.1", + "kind-of": "6.0.2", + "nanomatch": "1.2.9", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" }, "dependencies": { "kind-of": { @@ -2098,7 +2098,7 @@ "bundled": true, "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -2111,8 +2111,8 @@ "bundled": true, "dev": true, "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" + "for-in": "1.0.2", + "is-extendable": "1.0.1" }, "dependencies": { "is-extendable": { @@ -2120,7 +2120,7 @@ "bundled": true, "dev": true, "requires": { - "is-plain-object": "^2.0.4" + "is-plain-object": "2.0.4" } } } @@ -2143,18 +2143,18 @@ "bundled": true, "dev": true, "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-odd": "^2.0.0", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "fragment-cache": "0.2.1", + "is-odd": "2.0.0", + "is-windows": "1.0.2", + "kind-of": "6.0.2", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" }, "dependencies": { "arr-diff": { @@ -2179,10 +2179,10 @@ "bundled": true, "dev": true, "requires": { - "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" + "hosted-git-info": "2.6.0", + "is-builtin-module": "1.0.0", + "semver": "5.5.0", + "validate-npm-package-license": "3.0.3" } }, "npm-run-path": { @@ -2190,7 +2190,7 @@ "bundled": true, "dev": true, "requires": { - "path-key": "^2.0.0" + "path-key": "2.0.1" } }, "number-is-nan": { @@ -2208,9 +2208,9 @@ "bundled": true, "dev": true, "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" + "copy-descriptor": "0.1.1", + "define-property": "0.2.5", + "kind-of": "3.2.2" }, "dependencies": { "define-property": { @@ -2218,7 +2218,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } } } @@ -2228,7 +2228,7 @@ "bundled": true, "dev": true, "requires": { - "isobject": "^3.0.0" + "isobject": "3.0.1" }, "dependencies": { "isobject": { @@ -2243,7 +2243,7 @@ "bundled": true, "dev": true, "requires": { - "isobject": "^3.0.1" + "isobject": "3.0.1" }, "dependencies": { "isobject": { @@ -2258,7 +2258,7 @@ "bundled": true, "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "optimist": { @@ -2266,8 +2266,8 @@ "bundled": true, "dev": true, "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" + "minimist": "0.0.8", + "wordwrap": "0.0.3" } }, "os-homedir": { @@ -2280,9 +2280,9 @@ "bundled": true, "dev": true, "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" + "execa": "0.7.0", + "lcid": "1.0.0", + "mem": "1.1.0" } }, "p-finally": { @@ -2295,7 +2295,7 @@ "bundled": true, "dev": true, "requires": { - "p-try": "^1.0.0" + "p-try": "1.0.0" } }, "p-locate": { @@ -2303,7 +2303,7 @@ "bundled": true, "dev": true, "requires": { - "p-limit": "^1.1.0" + "p-limit": "1.2.0" } }, "p-try": { @@ -2316,7 +2316,7 @@ "bundled": true, "dev": true, "requires": { - "error-ex": "^1.2.0" + "error-ex": "1.3.1" } }, "pascalcase": { @@ -2329,7 +2329,7 @@ "bundled": true, "dev": true, "requires": { - "pinkie-promise": "^2.0.0" + "pinkie-promise": "2.0.1" } }, "path-is-absolute": { @@ -2352,9 +2352,9 @@ "bundled": true, "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" + "graceful-fs": "4.1.11", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" } }, "pify": { @@ -2372,7 +2372,7 @@ "bundled": true, "dev": true, "requires": { - "pinkie": "^2.0.0" + "pinkie": "2.0.4" } }, "pkg-dir": { @@ -2380,7 +2380,7 @@ "bundled": true, "dev": true, "requires": { - "find-up": "^1.0.0" + "find-up": "1.1.2" }, "dependencies": { "find-up": { @@ -2388,8 +2388,8 @@ "bundled": true, "dev": true, "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" } } } @@ -2409,9 +2409,9 @@ "bundled": true, "dev": true, "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" + "load-json-file": "1.1.0", + "normalize-package-data": "2.4.0", + "path-type": "1.1.0" } }, "read-pkg-up": { @@ -2419,8 +2419,8 @@ "bundled": true, "dev": true, "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" + "find-up": "1.1.2", + "read-pkg": "1.1.0" }, "dependencies": { "find-up": { @@ -2428,8 +2428,8 @@ "bundled": true, "dev": true, "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" } } } @@ -2444,8 +2444,8 @@ "bundled": true, "dev": true, "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" + "extend-shallow": "3.0.2", + "safe-regex": "1.1.0" } }, "repeat-element": { @@ -2463,7 +2463,7 @@ "bundled": true, "dev": true, "requires": { - "is-finite": "^1.0.0" + "is-finite": "1.0.2" } }, "require-directory": { @@ -2497,7 +2497,7 @@ "dev": true, "optional": true, "requires": { - "align-text": "^0.1.1" + "align-text": "0.1.4" } }, "rimraf": { @@ -2505,7 +2505,7 @@ "bundled": true, "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "7.1.2" } }, "safe-regex": { @@ -2513,7 +2513,7 @@ "bundled": true, "dev": true, "requires": { - "ret": "~0.1.10" + "ret": "0.1.15" } }, "semver": { @@ -2531,10 +2531,10 @@ "bundled": true, "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "split-string": "3.1.0" }, "dependencies": { "extend-shallow": { @@ -2542,7 +2542,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -2552,7 +2552,7 @@ "bundled": true, "dev": true, "requires": { - "shebang-regex": "^1.0.0" + "shebang-regex": "1.0.0" } }, "shebang-regex": { @@ -2575,14 +2575,14 @@ "bundled": true, "dev": true, "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" + "base": "0.11.2", + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "map-cache": "0.2.2", + "source-map": "0.5.7", + "source-map-resolve": "0.5.1", + "use": "3.1.0" }, "dependencies": { "define-property": { @@ -2590,7 +2590,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "extend-shallow": { @@ -2598,7 +2598,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -2608,9 +2608,9 @@ "bundled": true, "dev": true, "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" + "define-property": "1.0.0", + "isobject": "3.0.1", + "snapdragon-util": "3.0.1" }, "dependencies": { "define-property": { @@ -2618,7 +2618,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "is-accessor-descriptor": { @@ -2626,7 +2626,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -2634,7 +2634,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -2642,9 +2642,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" } }, "isobject": { @@ -2664,7 +2664,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.2.0" + "kind-of": "3.2.2" } }, "source-map": { @@ -2677,11 +2677,11 @@ "bundled": true, "dev": true, "requires": { - "atob": "^2.0.0", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" + "atob": "2.1.1", + "decode-uri-component": "0.2.0", + "resolve-url": "0.2.1", + "source-map-url": "0.4.0", + "urix": "0.1.0" } }, "source-map-url": { @@ -2694,12 +2694,12 @@ "bundled": true, "dev": true, "requires": { - "foreground-child": "^1.5.6", - "mkdirp": "^0.5.0", - "os-homedir": "^1.0.1", - "rimraf": "^2.6.2", - "signal-exit": "^3.0.2", - "which": "^1.3.0" + "foreground-child": "1.5.6", + "mkdirp": "0.5.1", + "os-homedir": "1.0.2", + "rimraf": "2.6.2", + "signal-exit": "3.0.2", + "which": "1.3.0" } }, "spdx-correct": { @@ -2707,8 +2707,8 @@ "bundled": true, "dev": true, "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" + "spdx-expression-parse": "3.0.0", + "spdx-license-ids": "3.0.0" } }, "spdx-exceptions": { @@ -2721,8 +2721,8 @@ "bundled": true, "dev": true, "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" + "spdx-exceptions": "2.1.0", + "spdx-license-ids": "3.0.0" } }, "spdx-license-ids": { @@ -2735,7 +2735,7 @@ "bundled": true, "dev": true, "requires": { - "extend-shallow": "^3.0.0" + "extend-shallow": "3.0.2" } }, "static-extend": { @@ -2743,8 +2743,8 @@ "bundled": true, "dev": true, "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" + "define-property": "0.2.5", + "object-copy": "0.1.0" }, "dependencies": { "define-property": { @@ -2752,7 +2752,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } } } @@ -2762,8 +2762,8 @@ "bundled": true, "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" }, "dependencies": { "ansi-regex": { @@ -2776,7 +2776,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -2786,7 +2786,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "strip-bom": { @@ -2794,7 +2794,7 @@ "bundled": true, "dev": true, "requires": { - "is-utf8": "^0.2.0" + "is-utf8": "0.2.1" } }, "strip-eof": { @@ -2812,11 +2812,11 @@ "bundled": true, "dev": true, "requires": { - "arrify": "^1.0.1", - "micromatch": "^3.1.8", - "object-assign": "^4.1.0", - "read-pkg-up": "^1.0.1", - "require-main-filename": "^1.0.1" + "arrify": "1.0.1", + "micromatch": "3.1.10", + "object-assign": "4.1.1", + "read-pkg-up": "1.0.1", + "require-main-filename": "1.0.1" }, "dependencies": { "arr-diff": { @@ -2834,16 +2834,16 @@ "bundled": true, "dev": true, "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" + "arr-flatten": "1.1.0", + "array-unique": "0.3.2", + "extend-shallow": "2.0.1", + "fill-range": "4.0.0", + "isobject": "3.0.1", + "repeat-element": "1.1.2", + "snapdragon": "0.8.2", + "snapdragon-node": "2.1.1", + "split-string": "3.1.0", + "to-regex": "3.0.2" }, "dependencies": { "extend-shallow": { @@ -2851,7 +2851,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -2861,13 +2861,13 @@ "bundled": true, "dev": true, "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "debug": "2.6.9", + "define-property": "0.2.5", + "extend-shallow": "2.0.1", + "posix-character-classes": "0.1.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" }, "dependencies": { "define-property": { @@ -2875,7 +2875,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "extend-shallow": { @@ -2883,7 +2883,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } }, "is-accessor-descriptor": { @@ -2891,7 +2891,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -2899,7 +2899,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -2909,7 +2909,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -2917,7 +2917,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -2927,9 +2927,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" } }, "kind-of": { @@ -2944,14 +2944,14 @@ "bundled": true, "dev": true, "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "array-unique": "0.3.2", + "define-property": "1.0.0", + "expand-brackets": "2.1.4", + "extend-shallow": "2.0.1", + "fragment-cache": "0.2.1", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" }, "dependencies": { "define-property": { @@ -2959,7 +2959,7 @@ "bundled": true, "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "extend-shallow": { @@ -2967,7 +2967,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -2977,10 +2977,10 @@ "bundled": true, "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" + "extend-shallow": "2.0.1", + "is-number": "3.0.0", + "repeat-string": "1.6.1", + "to-regex-range": "2.1.1" }, "dependencies": { "extend-shallow": { @@ -2988,7 +2988,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -2998,7 +2998,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -3006,7 +3006,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -3014,9 +3014,9 @@ "bundled": true, "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" } }, "is-number": { @@ -3024,7 +3024,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -3032,7 +3032,7 @@ "bundled": true, "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -3052,19 +3052,19 @@ "bundled": true, "dev": true, "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" + "arr-diff": "4.0.0", + "array-unique": "0.3.2", + "braces": "2.3.2", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "extglob": "2.0.4", + "fragment-cache": "0.2.1", + "kind-of": "6.0.2", + "nanomatch": "1.2.9", + "object.pick": "1.3.0", + "regex-not": "1.0.2", + "snapdragon": "0.8.2", + "to-regex": "3.0.2" } } } @@ -3079,7 +3079,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" } }, "to-regex": { @@ -3087,10 +3087,10 @@ "bundled": true, "dev": true, "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "regex-not": "1.0.2", + "safe-regex": "1.1.0" } }, "to-regex-range": { @@ -3098,8 +3098,8 @@ "bundled": true, "dev": true, "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" + "is-number": "3.0.0", + "repeat-string": "1.6.1" }, "dependencies": { "is-number": { @@ -3107,7 +3107,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" } } } @@ -3123,9 +3123,9 @@ "dev": true, "optional": true, "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" }, "dependencies": { "yargs": { @@ -3134,9 +3134,9 @@ "dev": true, "optional": true, "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", "window-size": "0.1.0" } } @@ -3153,10 +3153,10 @@ "bundled": true, "dev": true, "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^0.4.3" + "arr-union": "3.1.0", + "get-value": "2.0.6", + "is-extendable": "0.1.1", + "set-value": "0.4.3" }, "dependencies": { "extend-shallow": { @@ -3164,7 +3164,7 @@ "bundled": true, "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } }, "set-value": { @@ -3172,10 +3172,10 @@ "bundled": true, "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "to-object-path": "0.3.0" } } } @@ -3185,8 +3185,8 @@ "bundled": true, "dev": true, "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" + "has-value": "0.3.1", + "isobject": "3.0.1" }, "dependencies": { "has-value": { @@ -3194,9 +3194,9 @@ "bundled": true, "dev": true, "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" + "get-value": "2.0.6", + "has-values": "0.1.4", + "isobject": "2.1.0" }, "dependencies": { "isobject": { @@ -3231,7 +3231,7 @@ "bundled": true, "dev": true, "requires": { - "kind-of": "^6.0.2" + "kind-of": "6.0.2" }, "dependencies": { "kind-of": { @@ -3246,8 +3246,8 @@ "bundled": true, "dev": true, "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" + "spdx-correct": "3.0.0", + "spdx-expression-parse": "3.0.0" } }, "which": { @@ -3255,7 +3255,7 @@ "bundled": true, "dev": true, "requires": { - "isexe": "^2.0.0" + "isexe": "2.0.0" } }, "which-module": { @@ -3279,8 +3279,8 @@ "bundled": true, "dev": true, "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" + "string-width": "1.0.2", + "strip-ansi": "3.0.1" }, "dependencies": { "is-fullwidth-code-point": { @@ -3288,7 +3288,7 @@ "bundled": true, "dev": true, "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "string-width": { @@ -3296,9 +3296,9 @@ "bundled": true, "dev": true, "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" } } } @@ -3313,9 +3313,9 @@ "bundled": true, "dev": true, "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "slide": "^1.1.5" + "graceful-fs": "4.1.11", + "imurmurhash": "0.1.4", + "slide": "1.1.6" } }, "y18n": { @@ -3333,18 +3333,18 @@ "bundled": true, "dev": true, "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" + "cliui": "4.1.0", + "decamelize": "1.2.0", + "find-up": "2.1.0", + "get-caller-file": "1.0.2", + "os-locale": "2.1.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "3.2.1", + "yargs-parser": "9.0.2" }, "dependencies": { "ansi-regex": { @@ -3362,9 +3362,9 @@ "bundled": true, "dev": true, "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "wrap-ansi": "2.1.0" } }, "strip-ansi": { @@ -3372,7 +3372,7 @@ "bundled": true, "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } }, "yargs-parser": { @@ -3380,7 +3380,7 @@ "bundled": true, "dev": true, "requires": { - "camelcase": "^4.1.0" + "camelcase": "4.1.0" } } } @@ -3390,7 +3390,7 @@ "bundled": true, "dev": true, "requires": { - "camelcase": "^4.1.0" + "camelcase": "4.1.0" }, "dependencies": { "camelcase": { @@ -3414,7 +3414,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "os-locale": { @@ -3422,9 +3422,9 @@ "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" + "execa": "0.7.0", + "lcid": "1.0.0", + "mem": "1.1.0" } }, "os-tmpdir": { @@ -3443,7 +3443,7 @@ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", "requires": { - "p-try": "^2.0.0" + "p-try": "2.0.0" } }, "p-locate": { @@ -3451,7 +3451,7 @@ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "requires": { - "p-limit": "^2.0.0" + "p-limit": "2.0.0" } }, "p-try": { @@ -3516,13 +3516,13 @@ "integrity": "sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.0.3", - "util-deprecate": "~1.0.1" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, "readline-sync": { @@ -3543,26 +3543,26 @@ "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", "dev": true, "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", - "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", - "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "tough-cookie": "~2.3.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" + "aws-sign2": "0.7.0", + "aws4": "1.7.0", + "caseless": "0.12.0", + "combined-stream": "1.0.6", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.3.2", + "har-validator": "5.0.3", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.18", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.2", + "safe-buffer": "5.1.1", + "tough-cookie": "2.3.4", + "tunnel-agent": "0.6.0", + "uuid": "3.3.2" } }, "require-directory": { @@ -3581,7 +3581,7 @@ "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "1.0.5" } }, "safe-buffer": { @@ -3612,7 +3612,7 @@ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", "requires": { - "shebang-regex": "^1.0.0" + "shebang-regex": "1.0.0" } }, "shebang-regex": { @@ -3637,8 +3637,8 @@ "integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" + "buffer-from": "1.1.0", + "source-map": "0.6.1" } }, "sprintf-js": { @@ -3653,15 +3653,15 @@ "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", "dev": true, "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.2", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "safer-buffer": "2.1.2", + "tweetnacl": "0.14.5" } }, "string-width": { @@ -3669,8 +3669,8 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" }, "dependencies": { "ansi-regex": { @@ -3683,7 +3683,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "3.0.0" } } } @@ -3694,7 +3694,7 @@ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "5.1.1" } }, "strip-ansi": { @@ -3702,7 +3702,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "strip-eof": { @@ -3722,11 +3722,11 @@ "integrity": "sha1-bAPcUWh/7Xh3+COtSx3dHvXrVnQ=", "dev": true, "requires": { - "@types/node": ">=0.0.2", - "chalk": "^1.1.3", - "duplexer": "^0.1.1", - "tap-parser": "^3.0.3", - "through2": "^2.0.1" + "@types/node": "9.6.23", + "chalk": "1.1.3", + "duplexer": "0.1.1", + "tap-parser": "3.0.5", + "through2": "2.0.3" } }, "tap-parser": { @@ -3735,9 +3735,9 @@ "integrity": "sha1-uUf2ngs+U9S5IBH2zFUuFtrcfsk=", "dev": true, "requires": { - "events-to-array": "^1.0.1", - "js-yaml": "^3.2.7", - "readable-stream": "^2" + "events-to-array": "1.1.2", + "js-yaml": "3.10.0", + "readable-stream": "2.3.4" } }, "threads": { @@ -3746,8 +3746,8 @@ "integrity": "sha512-4B7hd61lDsVW1Z/+FAVX7D9QbiQYUbtGMHVkkwWT/nKPKas8u4FEc+Rg8E8h2erhNTQGNqNJ0TsholmhpKNPRg==", "dev": true, "requires": { - "eventemitter3": "^2.0.2", - "native-promise-only": "^0.8.1" + "eventemitter3": "2.0.3", + "native-promise-only": "0.8.1" } }, "through2": { @@ -3756,8 +3756,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "^2.1.5", - "xtend": "~4.0.1" + "readable-stream": "2.3.4", + "xtend": "4.0.1" } }, "tmp": { @@ -3766,7 +3766,7 @@ "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, "requires": { - "os-tmpdir": "~1.0.2" + "os-tmpdir": "1.0.2" } }, "tough-cookie": { @@ -3775,7 +3775,7 @@ "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { - "punycode": "^1.4.1" + "punycode": "1.4.1" } }, "ts-node": { @@ -3784,14 +3784,14 @@ "integrity": "sha512-klJsfswHP0FuOLsvBZ/zzCfUvakOSSxds78mVeK7I+qP76YWtxf16hEZsp3U+b0kIo82R5UatGFeblYMqabb2Q==", "dev": true, "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" + "arrify": "1.0.1", + "buffer-from": "1.1.0", + "diff": "3.4.0", + "make-error": "1.3.4", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "source-map-support": "0.5.6", + "yn": "2.0.0" } }, "tslib": { @@ -3806,18 +3806,18 @@ "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", "dev": true, "requires": { - "babel-code-frame": "^6.22.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^3.2.0", - "glob": "^7.1.1", - "js-yaml": "^3.7.0", - "minimatch": "^3.0.4", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.27.2" + "babel-code-frame": "6.26.0", + "builtin-modules": "1.1.1", + "chalk": "2.4.1", + "commander": "2.16.0", + "diff": "3.4.0", + "glob": "7.1.2", + "js-yaml": "3.10.0", + "minimatch": "3.0.4", + "resolve": "1.8.1", + "semver": "5.5.0", + "tslib": "1.9.3", + "tsutils": "2.28.0" }, "dependencies": { "ansi-styles": { @@ -3826,7 +3826,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "color-convert": "1.9.2" } }, "chalk": { @@ -3835,9 +3835,9 @@ "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" } }, "supports-color": { @@ -3846,7 +3846,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } } } @@ -3863,7 +3863,7 @@ "integrity": "sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==", "dev": true, "requires": { - "tslib": "^1.8.1" + "tslib": "1.9.3" } }, "tunnel-agent": { @@ -3872,7 +3872,7 @@ "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "dev": true, "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "5.1.1" } }, "tweetnacl": { @@ -3911,9 +3911,9 @@ "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "dev": true, "requires": { - "assert-plus": "^1.0.0", + "assert-plus": "1.0.0", "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" + "extsprintf": "1.3.0" } }, "which": { @@ -3921,7 +3921,7 @@ "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "requires": { - "isexe": "^2.0.0" + "isexe": "2.0.0" } }, "which-module": { @@ -3934,8 +3934,8 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" + "string-width": "1.0.2", + "strip-ansi": "3.0.1" }, "dependencies": { "is-fullwidth-code-point": { @@ -3943,7 +3943,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "requires": { - "number-is-nan": "^1.0.0" + "number-is-nan": "1.0.1" } }, "string-width": { @@ -3951,9 +3951,9 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" } } } @@ -3990,18 +3990,18 @@ "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.1.tgz", "integrity": "sha512-B0vRAp1hRX4jgIOWFtjfNjd9OA9RWYZ6tqGA9/I/IrTMsxmKvtWy+ersM+jzpQqbC3YfLzeABPdeTgcJ9eu1qQ==", "requires": { - "cliui": "^4.0.0", - "decamelize": "^2.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1 || ^4.0.0", - "yargs-parser": "^10.1.0" + "cliui": "4.1.0", + "decamelize": "2.0.0", + "find-up": "3.0.0", + "get-caller-file": "1.0.3", + "os-locale": "2.1.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "4.0.0", + "yargs-parser": "10.1.0" } }, "yargs-parser": { @@ -4009,7 +4009,7 @@ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", "requires": { - "camelcase": "^4.1.0" + "camelcase": "4.1.0" } }, "yn": { diff --git a/package.json b/package.json index d5b7f546f..334c88907 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "typescript-to-lua", "license": "MIT", - "version": "0.10.0", + "version": "0.12.1", "repository": "https://github.com/Perryvw/TypescriptToLua", "keywords": [ "typescript", diff --git a/src/Compiler.ts b/src/Compiler.ts index b15c3850f..1f2eaa8e4 100644 --- a/src/Compiler.ts +++ b/src/Compiler.ts @@ -193,19 +193,6 @@ export function transpileString(str: string, return result.trim(); } -export function transpileFile(filePath: string): string { - const program = ts.createProgram([filePath], {}); - const checker = program.getTypeChecker(); - - // Output errors - const diagnostics = ts.getPreEmitDiagnostics(program).filter(diag => diag.code !== 6054); - diagnostics.forEach(diagnostic => console.log(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`)); - - const options: ts.CompilerOptions = { luaLibImport: "none" }; - const result = createTranspiler(checker, options, program.getSourceFile(filePath)).transpileSourceFile(); - return result.trim(); -} - function reportDiagnostic(diagnostic: ts.Diagnostic): void { if (diagnostic.file) { const { line, character } = diff --git a/src/Decorator.ts b/src/Decorator.ts index e0b3b6a00..870cc9344 100644 --- a/src/Decorator.ts +++ b/src/Decorator.ts @@ -1,14 +1,30 @@ export class Decorator { + + public static isValid(decoratorKindString: string): boolean { + return this.getDecoratorKind(decoratorKindString) !== undefined; + } + + public static getDecoratorKind(decoratorKindString: string): DecoratorKind { + switch (decoratorKindString.toLowerCase()) { + case "extension": return DecoratorKind.Extension; + case "metaextension": return DecoratorKind.MetaExtension; + case "customconstructor": return DecoratorKind.CustomConstructor; + case "compilemembersonly": return DecoratorKind.CompileMembersOnly; + case "pureabstract": return DecoratorKind.PureAbstract; + case "phantom": return DecoratorKind.Phantom; + case "tuplereturn": return DecoratorKind.TupleReturn; + case "noclassor": return DecoratorKind.NoClassOr; + } + + return undefined; + } + public kind: DecoratorKind; public args: string[]; - constructor(raw: string) { - let nameEnd = raw.indexOf(" "); - if (nameEnd === -1) { - nameEnd = raw.length; - } - this.kind = DecoratorKind[raw.substring(1, nameEnd)]; - this.args = raw.split(" ").slice(1); + constructor(name: string, args: string[]) { + this.kind = Decorator.getDecoratorKind(name); + this.args = args; } } diff --git a/src/TSHelper.ts b/src/TSHelper.ts index 0ef1e355b..2f8cc7250 100644 --- a/src/TSHelper.ts +++ b/src/TSHelper.ts @@ -8,6 +8,25 @@ export enum ContextType { Mixed, } +const defaultArrayCallMethodNames = new Set([ + "concat", + "push", + "reverse", + "shift", + "unshift", + "sort", + "pop", + "forEach", + "indexOf", + "map", + "filter", + "some", + "every", + "slice", + "splice", + "join", +]); + export class TSHelper { // Reverse lookup of enum key by value @@ -68,6 +87,26 @@ export class TSHelper { || (ts.isBinaryExpression(node.parent) && ts.isArrayLiteralExpression(node.parent.left))); } + // iterate over a type and its bases until the callback returns true. + public static forTypeOrAnySupertype(type: ts.Type, checker: ts.TypeChecker, callback: (type: ts.Type) => boolean): + boolean { + if (callback(type)) { + return true; + } + if (!type.isClassOrInterface() && type.symbol) { + type = checker.getDeclaredTypeOfSymbol(type.symbol); + } + const baseTypes = type.getBaseTypes(); + if (baseTypes) { + for (const baseType of baseTypes) { + if (this.forTypeOrAnySupertype(baseType, checker, callback)) { + return true; + } + } + } + return false; + } + public static isStringType(type: ts.Type): boolean { return (type.flags & ts.TypeFlags.String) !== 0 || (type.flags & ts.TypeFlags.StringLike) !== 0 @@ -81,7 +120,7 @@ export class TSHelper { && (typeNode as ts.UnionOrIntersectionTypeNode).types.some(this.isArrayTypeNode)); } - public static isArrayType(type: ts.Type, checker: ts.TypeChecker): boolean { + public static isExplicitArrayType(type: ts.Type, checker: ts.TypeChecker): boolean { const typeNode = checker.typeToTypeNode(type, undefined, ts.NodeBuilderFlags.InTypeAlias); return typeNode && this.isArrayTypeNode(typeNode); } @@ -91,6 +130,10 @@ export class TSHelper { return typeNode && ts.isFunctionTypeNode(typeNode); } + public static isArrayType(type: ts.Type, checker: ts.TypeChecker): boolean { + return this.forTypeOrAnySupertype(type, checker, t => this.isExplicitArrayType(t, checker)); + } + public static isTupleReturnCall(node: ts.Node, checker: ts.TypeChecker): boolean { if (ts.isCallExpression(node)) { const type = checker.getTypeAtLocation(node.expression); @@ -130,12 +173,28 @@ export class TSHelper { const comments = symbol.getDocumentationComment(checker); const decorators = comments.filter(comment => comment.kind === "text") - .map(comment => comment.text.trim().split("\n")) + .map(comment => comment.text.split("\n")) .reduce((a, b) => a.concat(b), []) + .map(line => line.trim()) .filter(comment => comment[0] === "!"); + decorators.forEach(decStr => { - const dec = new Decorator(decStr); - decMap.set(dec.kind, dec); + const [decoratorName, ...decoratorArguments] = decStr.split(" "); + if (Decorator.isValid(decoratorName.substr(1))) { + const dec = new Decorator(decoratorName.substr(1), decoratorArguments); + decMap.set(dec.kind, dec); + console.warn(`[Deprecated] Decorators with ! are being deprecated, ` + + `use @${decStr.substr(1)} instead`); + } else { + console.warn(`Encountered unknown decorator ${decStr}.`); + } + }); + + symbol.getJsDocTags().forEach(tag => { + if (Decorator.isValid(tag.name)) { + const dec = new Decorator(tag.name, tag.text ? tag.text.split(" ") : []); + decMap.set(dec.kind, dec); + } }); } @@ -163,28 +222,34 @@ export class TSHelper { return null; } + public static hasExplicitGetAccessor(type: ts.Type, name: ts.__String): boolean { + if (type && type.symbol && type.symbol.members) { + const field = type.symbol.members.get(name); + return field && (field.flags & ts.SymbolFlags.GetAccessor) !== 0; + } + } + public static hasGetAccessor(node: ts.Node, checker: ts.TypeChecker): boolean { if (ts.isPropertyAccessExpression(node)) { const name = node.name.escapedText; const type = checker.getTypeAtLocation(node.expression); - - if (type && type.symbol && type.symbol.members) { - const field = type.symbol.members.get(name); - return field && (field.flags & ts.SymbolFlags.GetAccessor) !== 0; - } + return this.forTypeOrAnySupertype(type, checker, t => this.hasExplicitGetAccessor(t, name)); } return false; } + public static hasExplicitSetAccessor(type: ts.Type, name: ts.__String): boolean { + if (type && type.symbol && type.symbol.members) { + const field = type.symbol.members.get(name); + return field && (field.flags & ts.SymbolFlags.SetAccessor) !== 0; + } + } + public static hasSetAccessor(node: ts.Node, checker: ts.TypeChecker): boolean { if (ts.isPropertyAccessExpression(node)) { const name = node.name.escapedText; const type = checker.getTypeAtLocation(node.expression); - - if (type && type.symbol && type.symbol.members) { - const field = type.symbol.members.get(name); - return field && (field.flags & ts.SymbolFlags.SetAccessor) !== 0; - } + return this.forTypeOrAnySupertype(type, checker, t => this.hasExplicitSetAccessor(t, name)); } return false; } @@ -265,6 +330,10 @@ export class TSHelper { return [false, null, null]; } + public static isDefaultArrayCallMethodName(methodName: string): boolean { + return defaultArrayCallMethodNames.has(methodName); + } + public static getExplicitThisParameter(signatureDeclaration: ts.SignatureDeclaration): ts.ParameterDeclaration { return signatureDeclaration.parameters.find( param => ts.isIdentifier(param.name) && param.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword); diff --git a/src/Transpiler.ts b/src/Transpiler.ts index 845b42b9f..0f919b9f7 100644 --- a/src/Transpiler.ts +++ b/src/Transpiler.ts @@ -193,6 +193,34 @@ export abstract class LuaTranspiler { return filePath.replace(new RegExp("\\\\|\/", "g"), "."); } + public computeEnumMembers(node: ts.EnumDeclaration): Array<{ name: string, value: string | number }> { + let val: number | string = 0; + let hasStringInitializers = false; + + return node.members.map(member => { + if (member.initializer) { + if (ts.isNumericLiteral(member.initializer)) { + val = parseInt(member.initializer.text); + } else if (ts.isStringLiteral(member.initializer)) { + hasStringInitializers = true; + val = `"${member.initializer.text}"`; + } else { + throw TSTLErrors.InvalidEnumMember(member.initializer); + } + } else if (hasStringInitializers) { + throw TSTLErrors.HeterogeneousEnum(node); + } + + const enumMember = { name: this.transpileIdentifier(member.name as ts.Identifier), value: val }; + + if (typeof val === "number") { + val++; + } + + return enumMember; + }); + } + // Transpile a source file public transpileSourceFile(): string { let header = ""; @@ -214,7 +242,7 @@ export abstract class LuaTranspiler { } // Inline lualib features - if (this.options.luaLibImport === LuaLibImportKind.Inline) { + if (this.options.luaLibImport === LuaLibImportKind.Inline && this.luaLibFeatureSet.size > 0) { result += "\n" + "-- Lua Library Imports\n"; for (const feature of this.luaLibFeatureSet) { const featureFile = path.resolve(__dirname, `../dist/lualib/${feature}.lua`); @@ -318,9 +346,7 @@ export abstract class LuaTranspiler { public transpileLuaLibFunction(func: LuaLibFeature, ...params: string[]): string { this.importLuaLibFeature(func); - params = params.filter(element => { - return element.toString() !== ""; - }); + params = params.filter(element => element.toString() !== ""); return `__TS__${func}(${params.join(", ")})`; } @@ -402,48 +428,34 @@ export abstract class LuaTranspiler { } public transpileEnum(node: ts.EnumDeclaration): string { - let val: number | string = 0; - let result = ""; - const type = this.checker.getTypeAtLocation(node); + + // Const enums should never appear in the resulting code + if (type.symbol.getFlags() & ts.SymbolFlags.ConstEnum) { + return ""; + } + const membersOnly = tsHelper.getCustomDecorators(type, this.checker) .has(DecoratorKind.CompileMembersOnly); + let result = ""; + if (!membersOnly) { const name = this.transpileIdentifier(node.name); result += this.indent + this.accessPrefix(node) + `${name}={}\n`; this.pushExport(name, node); } - let hasStringInitializers = false; - node.members.forEach(member => { - if (member.initializer) { - if (ts.isNumericLiteral(member.initializer)) { - val = parseInt(member.initializer.text); - } else if (ts.isStringLiteral(member.initializer)) { - hasStringInitializers = true; - val = `"${member.initializer.text}"`; - } else { - throw TSTLErrors.InvalidEnumMember(member.initializer); - } - } else if (hasStringInitializers) { - throw TSTLErrors.HeterogeneousEnum(node); - } - + this.computeEnumMembers(node).forEach(enumMember => { if (membersOnly) { - const defName = this.definitionName(this.transpileIdentifier(member.name as ts.Identifier)); - result += this.indent + `${defName}=${val}\n`; + const defName = this.definitionName(enumMember.name); + result += this.indent + `${defName}=${enumMember.value}\n`; } else { - const defName = this.definitionName( - `${this.transpileIdentifier(node.name)}.${this.transpileIdentifier((member.name as ts.Identifier))}` - ); - result += this.indent + `${defName}=${val}\n`; - } - - if (typeof val === "number") { - val++; + const defName = `${this.transpileIdentifier(node.name)}.${enumMember.name}`; + result += this.indent + `${defName}=${enumMember.value}\n`; } }); + return result; } @@ -467,10 +479,20 @@ export abstract class LuaTranspiler { result += this.transpileStatement(node.thenStatement); this.popIndent(); - if (node.elseStatement) { + let elseStatement = node.elseStatement; + while (elseStatement && ts.isIfStatement(elseStatement)) { + const elseIfCondition = this.transpileExpression(elseStatement.expression); + result += this.indent + `elseif ${elseIfCondition} then\n`; + this.pushIndent(); + result += this.transpileStatement(elseStatement.thenStatement); + this.popIndent(); + elseStatement = elseStatement.elseStatement; + } + + if (elseStatement) { result += this.indent + "else\n"; this.pushIndent(); - result += this.transpileStatement(node.elseStatement); + result += this.transpileStatement(elseStatement); this.popIndent(); } @@ -541,21 +563,32 @@ export abstract class LuaTranspiler { const variable = (node.initializer as ts.VariableDeclarationList).declarations[0]; // Transpile expression - const expression = this.transpileExpression(node.expression); + const iterable = this.transpileExpression(node.expression); // Use ipairs for array types, pairs otherwise const isArray = tsHelper.isArrayType(this.checker.getTypeAtLocation(node.expression), this.checker); - const pairs = isArray ? "ipairs" : "pairs"; - // Make header let result = ""; - if (ts.isIdentifier(variable.name)) { - result = this.indent + `for _, ${this.transpileIdentifier(variable.name)} in ${pairs}(${expression}) do\n`; - } else if (ts.isArrayBindingPattern(variable.name)) { - const valueVar = "__forOfValue" + this.genVarCounter; - result = this.indent + `for _, ${valueVar} in ${pairs}(${expression}) do\n`; - const declaration = ts.createVariableDeclaration(variable.name, undefined, ts.createIdentifier(valueVar)); - result += this.indent + this.transpileVariableDeclaration(declaration); + + if (!isArray && ts.isIdentifier(variable.name)) { + result = this.indent + `for _, ${this.transpileIdentifier(variable.name)} in pairs(${iterable}) do\n`; + } else { + let itemVariable: ts.Identifier; + if (isArray) { + // Cache the expression result + result += this.indent + `local __loopVariable${this.genVarCounter} = ${iterable};\n`; + result += this.indent + `for i${this.genVarCounter}=1, #__loopVariable${this.genVarCounter} do\n`; + itemVariable = ts.createIdentifier(`__loopVariable${this.genVarCounter}[i${this.genVarCounter}]`); + } else { + const variableName = `__forOfValue${this.genVarCounter}`; + itemVariable = ts.createIdentifier(variableName); + result += this.indent + `for _, ${variableName} in pairs(${iterable}) do\n`; + } + + const declaration = ts.createVariableDeclaration(variable.name, undefined, itemVariable); + this.pushIndent(); + result += this.indent + this.transpileVariableDeclaration(declaration) + ";\n"; + this.popIndent(); } // For body @@ -563,6 +596,8 @@ export abstract class LuaTranspiler { result += this.transpileLoopBody(node); this.popIndent(); + this.genVarCounter++; + return result + this.indent + "end\n"; } @@ -598,96 +633,48 @@ export abstract class LuaTranspiler { } public transpileSwitch(node: ts.SwitchStatement): string { - const expression = this.transpileExpression(node.expression, true); - const clauses = node.caseBlock.clauses; - - let result = this.indent + "-------Switch statement start-------\n"; - - const switchVarName = "____switch" + this.genVarCounter; - this.genVarCounter++; - - result += this.indent + `local ${switchVarName} = ${expression}\n`; - - let hasDefaultClause = false; - - // If statement to go to right entry label - clauses.forEach((clause, index) => { - if (ts.isCaseClause(clause)) { - result += this.indent + - `if ${this.transpileExpression(clause.expression, true)} == ${switchVarName} then\n`; + throw TSTLErrors.UnsupportedForTarget("Switch statements", this.options.luaTarget, node); + } - this.pushIndent(); - result += this.indent + `goto ${switchVarName}_case_${index}\n`; - this.popIndent(); + public transpileTry(node: ts.TryStatement): string { + let result = this.indent + "do\n"; + this.pushIndent(); - result += this.indent + "end\n"; - } else if (ts.isDefaultClause(clause)) { - hasDefaultClause = true; + result += this.indent; + if (node.catchClause) { + result += "local __TS_try"; + if (node.catchClause.variableDeclaration) { + const variableName = this.transpileIdentifier( + node.catchClause.variableDeclaration.name as ts.Identifier); + result += ", " + variableName; } - }); - - result += "\n"; - - // If no case condition is matched jump to end or default immediately - if (hasDefaultClause) { - result += this.indent + `goto ${switchVarName}_default\n`; - } else { - result += this.indent + `goto ${switchVarName}_end\n`; + result += " = "; } - result += "\n"; - - const transpileClauseBody = (clause: ts.CaseOrDefaultClause) => { - this.transpilingSwitch++; - result += this.indent + "do\n"; - this.pushIndent(); - result += this.transpileBlock(ts.createBlock(clause.statements)); - this.popIndent(); - result += this.indent + "end\n"; - this.transpilingSwitch--; - }; - - clauses.forEach((clause, index) => { - if (ts.isCaseClause(clause)) { - result += this.indent + `::${switchVarName}_case_${index}::\n`; - - transpileClauseBody(clause); - - if (tsHelper.containsStatement(clause.statements, ts.SyntaxKind.BreakStatement)) { - result += this.indent + `goto ${switchVarName}_end\n`; - } - } else if (ts.isDefaultClause(clause)) { - result += this.indent + `::${switchVarName}_default::\n`; - - transpileClauseBody(clause); - } - }); - - result += this.indent + `::${switchVarName}_end::\n`; - result += this.indent + "-------Switch statement end-------\n"; - - return result; - } - - public transpileTry(node: ts.TryStatement): string { - let tryFunc = "function()\n"; + result += "pcall(function()\n"; this.pushIndent(); - tryFunc += this.transpileBlock(node.tryBlock); + result += this.transpileBlock(node.tryBlock); this.popIndent(); - tryFunc += "end"; - let catchFunc = "function(e)\nend"; - if (node.catchClause && node.catchClause.variableDeclaration) { - const variableName = this.transpileIdentifier(node.catchClause.variableDeclaration.name as ts.Identifier); - catchFunc = this.indent + `function(${variableName})\n`; + result += this.indent + "end);\n"; + + if (node.catchClause) { + result += this.indent + `if not __TS_try then\n`; this.pushIndent(); - catchFunc += this.transpileBlock(node.catchClause.block); + result += this.transpileBlock(node.catchClause.block); this.popIndent(); - catchFunc += "end"; + result += this.indent + "end\n"; } - let result = this.indent + `xpcall(${tryFunc},\n${catchFunc})\n`; + if (node.finallyBlock) { + result += this.indent + "do\n"; + this.pushIndent(); result += this.transpileBlock(node.finallyBlock); + this.popIndent(); + result += this.indent + "end\n"; } + + this.popIndent(); + result += this.indent + "end\n"; return result; } @@ -1249,7 +1236,14 @@ export abstract class LuaTranspiler { } - if (tsHelper.isArrayType(ownerType, this.checker)) { + // if ownerType is a array, use only supported functions + if (tsHelper.isExplicitArrayType(ownerType, this.checker)) { + return this.transpileArrayCallExpression(node); + } + + // if ownerType inherits from an array, use array calls where appropriate + if (tsHelper.isArrayType(ownerType, this.checker) + && tsHelper.isDefaultArrayCallMethodName(this.transpileIdentifier(node.expression.name))) { return this.transpileArrayCallExpression(node); } @@ -1525,6 +1519,33 @@ export abstract class LuaTranspiler { } } + if (type.symbol && (type.symbol.flags & ts.SymbolFlags.ConstEnum)) { + const propertyValueDeclaration = this.checker.getTypeAtLocation(node).symbol.valueDeclaration; + + if (propertyValueDeclaration && propertyValueDeclaration.kind === ts.SyntaxKind.EnumMember) { + const enumMember = propertyValueDeclaration as ts.EnumMember; + + if (enumMember.initializer) { + return this.transpileExpression(enumMember.initializer); + } else { + const enumMembers = this.computeEnumMembers(enumMember.parent); + const memberPosition = enumMember.parent.members.indexOf(enumMember); + + if (memberPosition === -1) { + throw TSTLErrors.UnsupportedProperty(type.symbol.name, property, node); + } + + const value = enumMembers[memberPosition].value; + + if (typeof value === "string") { + return `"${value}"`; + } + + return value.toString(); + } + } + } + this.checkForLuaLibType(type); const decorators = tsHelper.getCustomDecorators(type, this.checker); @@ -1677,7 +1698,7 @@ export abstract class LuaTranspiler { } public transpileDestructingAssignmentValue(node: ts.Expression): string { - throw TSTLErrors.UnsupportedForTarget("Destructing statements", this.options.luaTarget, node); + return `unpack(${this.transpileExpression(node)})`; } public transpileVariableDeclaration(node: ts.VariableDeclaration): string { @@ -1905,12 +1926,13 @@ export abstract class LuaTranspiler { result += this.indent + `${className}.${fieldName} = ${value}\n`; } - // Try to find constructor - const constructor = node.members.filter(ts.isConstructorDeclaration)[0]; + // Find first constructor with body + const constructor = + node.members.filter(n => ts.isConstructorDeclaration(n) && n.body)[0] as ts.ConstructorDeclaration; if (constructor) { // Add constructor plus initialization of instance fields result += this.transpileConstructor(constructor, className); - } else if (!isExtension) { + } else if (!isExtension && !extendsType) { // Generate a constructor if none was defined result += this.transpileConstructor(ts.createConstructor([], [], [], ts.createBlock([], true)), className); @@ -2020,29 +2042,30 @@ export abstract class LuaTranspiler { // Don't transpile methods without body (overload declarations) if (!node.body) { return ""; } - const extraInstanceFields = []; + // Check for field declarations in constructor + const constructorFieldsDeclarations = node.parameters.filter(p => p.modifiers !== undefined); - const parameters = ["self"]; - node.parameters.forEach(param => { - // If param has decorators, add extra instance field - if (param.modifiers !== undefined) { - extraInstanceFields.push(this.transpileIdentifier(param.name as ts.Identifier)); - } - // Add to parameter list - parameters.push(this.transpileIdentifier(param.name as ts.Identifier)); - }); - - let result = this.indent + `function ${className}.constructor(${parameters.join(",")})\n`; + const [paramNames, spreadIdentifier] = this.transpileParameters(node.parameters, null); - // Add in instance field declarations - for (const f of extraInstanceFields) { - result += this.indent + ` self.${f} = ${f}\n`; - } + let result = this.indent + `function ${className}.constructor(${["self"].concat(paramNames).join(",")})\n`; // Transpile constructor body this.pushIndent(); this.classStack.push(className); - result += this.transpileBlock(node.body); + + // Add in instance field declarations + for (const declaration of constructorFieldsDeclarations) { + const declarationName = this.transpileIdentifier(declaration.name as ts.Identifier); + if (declaration.initializer) { + const value = this.transpileExpression(declaration.initializer); + result += this.indent + `self.${declarationName} = ${declarationName} or ${value}\n`; + } else { + result += this.indent + `self.${declarationName} = ${declarationName}\n`; + } + } + + result += this.transpileFunctionBody(node.parameters, node.body, spreadIdentifier); + this.classStack.pop(); this.popIndent(); diff --git a/src/lualib/StringReplace.ts b/src/lualib/StringReplace.ts index 7a5df979c..7324db680 100644 --- a/src/lualib/StringReplace.ts +++ b/src/lualib/StringReplace.ts @@ -1,5 +1,5 @@ declare namespace string { - /** !TupleReturn */ + /** @tupleReturn */ function gsub(source: string, searchValue: string, replaceValue: string): [string, number]; } diff --git a/src/targets/Transpiler.51.ts b/src/targets/Transpiler.51.ts index f84d74fe6..bd4d63359 100644 --- a/src/targets/Transpiler.51.ts +++ b/src/targets/Transpiler.51.ts @@ -4,8 +4,5 @@ import { TSHelper as tsHelper } from "../TSHelper"; import * as ts from "typescript"; export class LuaTranspiler51 extends LuaTranspiler { - /** @override */ - public transpileDestructingAssignmentValue(node: ts.Expression): string { - return `unpack(${this.transpileExpression(node)})`; - } + } diff --git a/src/targets/Transpiler.52.ts b/src/targets/Transpiler.52.ts index 31a6f4dcb..0fcba461f 100644 --- a/src/targets/Transpiler.52.ts +++ b/src/targets/Transpiler.52.ts @@ -59,6 +59,79 @@ export class LuaTranspiler52 extends LuaTranspiler51 { } } + /** @override */ + public transpileSwitch(node: ts.SwitchStatement): string { + const expression = this.transpileExpression(node.expression, true); + const clauses = node.caseBlock.clauses; + + let result = this.indent + "-------Switch statement start-------\n"; + + const switchVarName = "____switch" + this.genVarCounter; + this.genVarCounter++; + + result += this.indent + `local ${switchVarName} = ${expression}\n`; + + let hasDefaultClause = false; + + // If statement to go to right entry label + clauses.forEach((clause, index) => { + if (ts.isCaseClause(clause)) { + result += this.indent + + `if ${this.transpileExpression(clause.expression, true)} == ${switchVarName} then\n`; + + this.pushIndent(); + result += this.indent + `goto ${switchVarName}_case_${index}\n`; + this.popIndent(); + + result += this.indent + "end\n"; + } else if (ts.isDefaultClause(clause)) { + hasDefaultClause = true; + } + }); + + result += "\n"; + + // If no case condition is matched jump to end or default immediately + if (hasDefaultClause) { + result += this.indent + `goto ${switchVarName}_default\n`; + } else { + result += this.indent + `goto ${switchVarName}_end\n`; + } + + result += "\n"; + + const transpileClauseBody = (clause: ts.CaseOrDefaultClause) => { + this.transpilingSwitch++; + result += this.indent + "do\n"; + this.pushIndent(); + result += this.transpileBlock(ts.createBlock(clause.statements)); + this.popIndent(); + result += this.indent + "end\n"; + this.transpilingSwitch--; + }; + + clauses.forEach((clause, index) => { + if (ts.isCaseClause(clause)) { + result += this.indent + `::${switchVarName}_case_${index}::\n`; + + transpileClauseBody(clause); + + if (tsHelper.containsStatement(clause.statements, ts.SyntaxKind.BreakStatement)) { + result += this.indent + `goto ${switchVarName}_end\n`; + } + } else if (ts.isDefaultClause(clause)) { + result += this.indent + `::${switchVarName}_default::\n`; + + transpileClauseBody(clause); + } + }); + + result += this.indent + `::${switchVarName}_end::\n`; + result += this.indent + "-------Switch statement end-------\n"; + + return result; + } + /** @override */ public transpileDestructingAssignmentValue(node: ts.Expression): string { return `table.unpack(${this.transpileExpression(node)})`; diff --git a/src/targets/Transpiler.JIT.ts b/src/targets/Transpiler.JIT.ts index 8aa2c2b36..a23e3a8e2 100644 --- a/src/targets/Transpiler.JIT.ts +++ b/src/targets/Transpiler.JIT.ts @@ -34,4 +34,14 @@ export class LuaTranspilerJIT extends LuaTranspiler52 { throw TSTLErrors.UnsupportedKind("bitwise operator", node.operatorToken.kind, node); } } + + /** @override */ + public transpileDestructingAssignmentValue(node: ts.Expression): string { + return `unpack(${this.transpileExpression(node)})`; + } + + /** @override */ + public transpileSpreadElement(node: ts.SpreadElement): string { + return "unpack(" + this.transpileExpression(node.expression) + ")"; + } } diff --git a/src/tstl.ts b/src/tstl.ts index cef7e8cc0..31174588c 100644 --- a/src/tstl.ts +++ b/src/tstl.ts @@ -9,7 +9,6 @@ export { export { compile, compileFilesWithOptions, - transpileFile, transpileString, watchWithOptions } from "./Compiler"; diff --git a/test/runner.ts b/test/runner.ts index 0d5d542fc..b37dbe17f 100644 --- a/test/runner.ts +++ b/test/runner.ts @@ -1,5 +1,4 @@ -import { TestRunner, TestSet } from "alsatian"; -import { TapBark } from "tap-bark"; +import { TestRunner, TestSet, TestOutcome } from "alsatian"; import * as fs from "fs"; import * as path from "path"; @@ -21,21 +20,44 @@ fs.copyFileSync( // setup the output testRunner.outputStream - // this will use alsatian's default output if you remove this - // you'll get TAP or you can add your favourite TAP reporter in it's place - .pipe(TapBark.create().getPipeable()) - // pipe to the console - .pipe(process.stdout); + // pipe to the console + .pipe(process.stdout); + +let success = 0; +let ignored = 0; +let run = 0; +testRunner.onTestComplete(test => { + run++; + + if (test.outcome === TestOutcome.Pass) { + success++; + } else if (test.outcome === TestOutcome.Skip) { + ignored++; + } +}); // run the test set testRunner.run(testSet) - // this will be called after all tests have been run - .then(result => { - // Remove lualib bundle again - fs.unlinkSync("lualib_bundle.lua"); - }) - // this will be called if there was a problem - .catch(error => { - // Remove lualib bundle again - fs.unlinkSync("lualib_bundle.lua"); - }); + // this will be called after all tests have been run + .then(result => { + // Remove lualib bundle again + fs.unlinkSync("lualib_bundle.lua"); + + const nonIgnoredTests = run - ignored; + const failedTests = nonIgnoredTests - success; + console.log(`Ignored ${ignored}/${run} tests.`); + console.log(`Failed ${failedTests}/${nonIgnoredTests} tests.`); + console.log(`Passed ${success}/${nonIgnoredTests} tests.`); + + if (failedTests > 0) { + process.exit(1); + } + }) + // this will be called if there was a problem + .catch(error => { + // Remove lualib bundle again + fs.unlinkSync("lualib_bundle.lua"); + + console.error(error); + process.exit(1); + }); diff --git a/test/src/util.ts b/test/src/util.ts index 490323d3e..5cec02dde 100644 --- a/test/src/util.ts +++ b/test/src/util.ts @@ -68,6 +68,54 @@ export function transpileAndExecute(tsStr: string): any { return executeLua(transpileString(tsStr)); } +export function parseTypeScript(typescript: string, target: LuaTarget = LuaTarget.Lua53) + : [ts.SourceFile, ts.TypeChecker] { + const compilerHost = { + directoryExists: () => true, + fileExists: (fileName): boolean => true, + getCanonicalFileName: fileName => fileName, + getCurrentDirectory: () => "", + getDefaultLibFileName: () => "lib.es6.d.ts", + getDirectories: () => [], + getNewLine: () => "\n", + + getSourceFile: (filename, languageVersion) => { + if (filename === "file.ts") { + return ts.createSourceFile(filename, typescript, ts.ScriptTarget.Latest, false); + } + if (filename === "lib.es6.d.ts") { + const libPath = path.join(path.dirname(require.resolve("typescript")), "lib.es6.d.ts"); + const libSource = fs.readFileSync(libPath).toString(); + return ts.createSourceFile(filename, libSource, ts.ScriptTarget.Latest, false); + } + return undefined; + }, + + readFile: () => "", + + useCaseSensitiveFileNames: () => false, + // Don't write output + writeFile: (name, text, writeByteOrderMark) => null, + }; + + const program = ts.createProgram(["file.ts"], { luaTarget: target }, compilerHost); + return [program.getSourceFile("file.ts"), program.getTypeChecker()]; +} + +export function findFirstChild(node: ts.Node, predicate: (node: ts.Node) => boolean): ts.Node | undefined { + for (const child of node.getChildren()) { + if (predicate(child)) { + return child; + } + + const childChild = findFirstChild(child, predicate); + if (childChild !== undefined) { + return childChild; + } + } + return undefined; +} + const jsonlib = fs.readFileSync("test/src/json.lua") + "\n"; export const minimalTestLib = jsonlib; diff --git a/test/translation/lua/assignments.lua b/test/translation/lua/assignments.lua deleted file mode 100644 index 6f4e5f9bd..000000000 --- a/test/translation/lua/assignments.lua +++ /dev/null @@ -1,143 +0,0 @@ -x = y; -x = obj.prop; -x = arr[(0)+1]; -x = ((function() local __TS_tmp = obj.prop; y = __TS_tmp; return __TS_tmp end)()); -x = obj.prop; -obj.prop = x; -arr[(0)+1] = x; -obj.prop = arr[(0)+1]; -obj.prop = ((function() arr[(0)+1] = x; return x end)()); -xTup = getTup(); -xTup = ({ getTupRet() }); -do local __TS_tmp0,__TS_tmp1 = table.unpack(getTup()); xTup[(1)+1],xTup[(0)+1] = __TS_tmp0,__TS_tmp1 end; -do local __TS_tmp0,__TS_tmp1 = getTupRet(); xTup[(1)+1],xTup[(0)+1] = __TS_tmp0,__TS_tmp1 end; -xTup = {yTup[(1)+1],yTup[(0)+1]}; -do local __TS_tmp0,__TS_tmp1 = table.unpack({yTup[(1)+1],yTup[(0)+1]}); xTup[(0)+1],xTup[(1)+1] = __TS_tmp0,__TS_tmp1 end; -x = (x+1); -x = (x+1); -x = (x-1); -x = (x-1); -x = (x+y); -x = (x-y); -x = (x*y); -y = (y/x); -y = (y%x); -y = (y^x); -x = (x | y); -x = (x & y); -x = (x ~ y); -x = (x << y); -x = (x >> y); -obj.prop = (obj.prop+1); -obj.prop = (obj.prop+1); -obj.prop = (obj.prop-1); -obj.prop = (obj.prop-1); -obj.prop = (obj.prop+arr[(0)+1]); -obj.prop = (obj.prop-arr[(0)+1]); -obj.prop = (obj.prop*arr[(0)+1]); -arr[(0)+1] = (arr[(0)+1]/obj.prop); -arr[(0)+1] = (arr[(0)+1]%obj.prop); -arr[(0)+1] = (arr[(0)+1]^obj.prop); -obj.prop = (obj.prop | arr[(0)+1]); -obj.prop = (obj.prop & arr[(0)+1]); -obj.prop = (obj.prop ~ arr[(0)+1]); -obj.prop = (obj.prop << arr[(0)+1]); -obj.prop = (obj.prop >> arr[(0)+1]); -do local __TS_obj, __TS_index = arr, (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = arr, (getIndex())+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp-(1)); end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]-(1)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp-(1)); end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]+(getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]-(getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]*(getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]/(getObj().prop)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]%(getObj().prop)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]^(getObj().prop)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] | (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] & (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] ~ (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] << (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] >> (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; end; -z = ((function() x = y; return y end)()); -z = ((function() obj.prop = x; return x end)()); -z = ((function(o, i, v) o[i] = v; return v end)(getObj(), "prop", x)); -z = ((function() arr[(0)+1] = x; return x end)()); -z = ((function(o, i, v) o[i] = v; return v end)(getArr(), (getIndex())+1, x)); -z = ((function() local __TS_tmp = obj.prop; x = __TS_tmp; return __TS_tmp end)()); -z = ((function() local __TS_tmp = getObj().prop; x = __TS_tmp; return __TS_tmp end)()); -z = ((function() local __TS_tmp = arr[(0)+1]; x = __TS_tmp; return __TS_tmp end)()); -z = ((function() local __TS_tmp = arr[(getIndex())+1]; x = __TS_tmp; return __TS_tmp end)()); -z = ((function() local __TS_tmp = getArr()[(getIndex())+1]; x = __TS_tmp; return __TS_tmp end)()); -z = (function() x = (x+1); return x end)(); -z = (function() local __TS_tmp = x; x = (__TS_tmp+1); return __TS_tmp end)(); -z = (function() x = (x-1); return x end)(); -z = (function() local __TS_tmp = x; x = (__TS_tmp-1); return __TS_tmp end)(); -z = (function() x = (x+y); return x end)(); -z = (function() x = (x-y); return x end)(); -z = (function() x = (x*y); return x end)(); -z = (function() y = (y/x); return y end)(); -z = (function() y = (y%x); return y end)(); -z = (function() y = (y^x); return y end)(); -z = (function() x = (x | y); return x end)(); -z = (function() x = (x & y); return x end)(); -z = (function() x = (x ~ y); return x end)(); -z = (function() x = (x << y); return x end)(); -z = (function() x = (x >> y); return x end)(); -z = (x+((function() y = (y+7); return y end)())); -z = (x+((function() y = (y+7); return y end)())); -z = ((function() local __TS_tmp = x; x = (__TS_tmp+1); return __TS_tmp end)()+((function() y = (y+7); return y end)())); -z = (function() local __TS_tmp = (obj.prop+1); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = obj.prop; obj.prop = (__TS_tmp+1); return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop-1); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = obj.prop; obj.prop = (__TS_tmp-1); return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop+arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop-arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop*arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (arr[(0)+1]/obj.prop); arr[(0)+1] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (arr[(0)+1]%obj.prop); arr[(0)+1] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (arr[(0)+1]^obj.prop); arr[(0)+1] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop | arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop & arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop ~ arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop << arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_tmp = (obj.prop >> arr[(0)+1]); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = (obj.prop+((function() local __TS_tmp = (arr[(0)+1]+7); arr[(0)+1] = __TS_tmp; return __TS_tmp end)())); -z = (function() local __TS_tmp = (obj.prop+((function() local __TS_tmp = (arr[(0)+1]+7); arr[(0)+1] = __TS_tmp; return __TS_tmp end)())); obj.prop = __TS_tmp; return __TS_tmp end)(); -z = ((function() local __TS_tmp = obj.prop; obj.prop = (__TS_tmp+1); return __TS_tmp end)()+((function() local __TS_tmp = (arr[(0)+1]+7); arr[(0)+1] = __TS_tmp; return __TS_tmp end)())); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]-(1)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp-(1)); return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]+(getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]-(getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]*(getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]/(getObj().prop)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]%(getObj().prop)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]^(getObj().prop)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] | (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] & (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] ~ (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] << (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index] >> (getArr()[(getIndex())+1])); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (getObj().prop+((function() local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(7)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)())); -z = (function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = (__TS_obj[__TS_index]+(((function() local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(7)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)()))); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = ((function() local __TS_obj, __TS_index = getObj(), "prop"; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); return __TS_tmp end)()+((function() local __TS_obj, __TS_index = getArr(), (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(7)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)())); -do local __TS_obj, __TS_index = getObj().arr, (0)+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = getObj().arr, (0)+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); end; -do local __TS_obj, __TS_index = getObj().arr, (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(13)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = arr2[(0)+1], (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = arr2[(0)+1], (getIndex())+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); end; -do local __TS_obj, __TS_index = arr2[(getIndex())+1], (0)+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; end; -do local __TS_obj, __TS_index = arr2[(getIndex())+1], (0)+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); end; -z = (function() local __TS_obj, __TS_index = getObj().arr, (0)+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj().arr, (0)+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = getObj().arr, (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(13)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = arr2[(0)+1], (getIndex())+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = arr2[(0)+1], (getIndex())+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = arr2[(getIndex())+1], (0)+1; local __TS_tmp = (__TS_obj[__TS_index]+(1)); __TS_obj[__TS_index] = __TS_tmp; return __TS_tmp end)(); -z = (function() local __TS_obj, __TS_index = arr2[(getIndex())+1], (0)+1; local __TS_tmp = __TS_obj[__TS_index]; __TS_obj[__TS_index] = (__TS_tmp+(1)); return __TS_tmp end)(); -z = ((function() local __TS_tmp = arr2[(0)+1][(getIndex())+1]; x = __TS_tmp; return __TS_tmp end)()); -z = ((function(o, i, v) o[i] = v; return v end)(getObj().arr, (0)+1, x)); -z = ((function(o, i, v) o[i] = v; return v end)(getObj().arr, (0)+1, arr2[(0)+1][(getIndex())+1])); diff --git a/test/translation/lua/forOf.lua b/test/translation/lua/forOf.lua index 79c0a9fed..4a7ca76a9 100644 --- a/test/translation/lua/forOf.lua +++ b/test/translation/lua/forOf.lua @@ -1,4 +1,6 @@ -for _, i in ipairs({1,2,3,4,5,6,7,8,9,10}) do +local __loopVariable0 = {1,2,3,4,5,6,7,8,9,10}; +for i0=1, #__loopVariable0 do + local i = __loopVariable0[i0]; do end ::__continue0:: diff --git a/test/translation/lua/modulesNamespaceExportEnum.lua b/test/translation/lua/modulesNamespaceExportEnum.lua new file mode 100644 index 000000000..002807a03 --- /dev/null +++ b/test/translation/lua/modulesNamespaceExportEnum.lua @@ -0,0 +1,10 @@ +local exports = exports or {} +local test = exports.test or test or {} +do + local TestEnum={} + TestEnum.foo="foo" + TestEnum.bar="bar" + test.TestEnum = TestEnum +end +exports.test = test +return exports diff --git a/test/translation/lua/tryCatch.lua b/test/translation/lua/tryCatch.lua index 082aafc57..c5df1423b 100644 --- a/test/translation/lua/tryCatch.lua +++ b/test/translation/lua/tryCatch.lua @@ -1,6 +1,8 @@ -xpcall(function() - local a = 42; -end, -function(er) - local b = "fail"; -end) +do + local __TS_try, er = pcall(function() + local a = 42; + end); + if not __TS_try then + local b = "fail"; + end +end diff --git a/test/translation/lua/tryCatchFinally.lua b/test/translation/lua/tryCatchFinally.lua index c08fa2bc4..ac0269f8c 100644 --- a/test/translation/lua/tryCatchFinally.lua +++ b/test/translation/lua/tryCatchFinally.lua @@ -1,7 +1,11 @@ -xpcall(function() - local a = 42; -end, -function(er) - local b = "fail"; -end) -local c = "finally"; +do + local __TS_try, er = pcall(function() + local a = 42; + end); + if not __TS_try then + local b = "fail"; + end + do + local c = "finally"; + end +end diff --git a/test/translation/lua/tryFinally.lua b/test/translation/lua/tryFinally.lua index 4eb2f1c34..a117b8bb2 100644 --- a/test/translation/lua/tryFinally.lua +++ b/test/translation/lua/tryFinally.lua @@ -1,6 +1,8 @@ -xpcall(function() - local a = 42; -end, -function(e) -end) -local b = "finally"; +do + pcall(function() + local a = 42; + end); + do + local b = "finally"; + end +end diff --git a/test/translation/ts/assignments.ts b/test/translation/ts/assignments.ts deleted file mode 100644 index a8e51e59a..000000000 --- a/test/translation/ts/assignments.ts +++ /dev/null @@ -1,157 +0,0 @@ -declare let x: number; -declare let y: number; -declare let z: number; -declare let obj: {prop: number, arr: number[]}; -declare function getObj(): typeof obj; -declare let arr: number[]; -declare let arr2: number[][]; -declare function getArr(): typeof arr; -declare function getIndex(): number; -declare let xTup: [number, number]; -declare let yTup: [number, number]; -declare function getTup(): [number, number]; -/** !TupleReturn */ -declare function getTupRet(): [number, number]; -x = y; -x = obj.prop; -x = arr[0]; -x = y = obj.prop; -x = obj.prop; -obj.prop = x; -arr[0] = x; -obj.prop = arr[0]; -obj.prop = arr[0] = x; -xTup = getTup(); -xTup = getTupRet(); -[xTup[1], xTup[0]] = getTup(); -[xTup[1], xTup[0]] = getTupRet(); -xTup = [yTup[1], yTup[0]]; -[xTup[0], xTup[1]] = [yTup[1], yTup[0]]; -++x; -x++; ---x; -x--; -x += y; -x -= y; -x *= y; -y /= x; -y %= x; -y **= x; -x |= y; -x &= y; -x ^= y; -x <<= y; -x >>= y; -++obj.prop; -obj.prop++; ---obj.prop; -obj.prop--; -obj.prop += arr[0]; -obj.prop -= arr[0]; -obj.prop *= arr[0]; -arr[0] /= obj.prop; -arr[0] %= obj.prop; -arr[0] **= obj.prop; -obj.prop |= arr[0]; -obj.prop &= arr[0]; -obj.prop ^= arr[0]; -obj.prop <<= arr[0]; -obj.prop >>= arr[0]; -++arr[getIndex()]; -arr[getIndex()]--; -++getObj().prop; -getObj().prop++; ---getObj().prop; -getObj().prop--; -getObj().prop += getArr()[getIndex()]; -getObj().prop -= getArr()[getIndex()]; -getObj().prop *= getArr()[getIndex()]; -getArr()[getIndex()] /= getObj().prop; -getArr()[getIndex()] %= getObj().prop; -getArr()[getIndex()] **= getObj().prop; -getObj().prop |= getArr()[getIndex()]; -getObj().prop &= getArr()[getIndex()]; -getObj().prop ^= getArr()[getIndex()]; -getObj().prop <<= getArr()[getIndex()]; -getObj().prop >>= getArr()[getIndex()]; -z = x = y; -z = obj.prop = x; -z = getObj().prop = x; -z = arr[0] = x; -z = getArr()[getIndex()] = x; -z = x = obj.prop; -z = x = getObj().prop; -z = x = arr[0]; -z = x = arr[getIndex()]; -z = x = getArr()[getIndex()]; -z = ++x; -z = x++; -z = --x; -z = x--; -z = x += y; -z = x -= y; -z = x *= y; -z = y /= x; -z = y %= x; -z = y **= x; -z = x |= y; -z = x &= y; -z = x ^= y; -z = x <<= y; -z = x >>= y; -z = x + (y += 7); -z = x + (y += 7); -z = x++ + (y += 7); -z = ++obj.prop; -z = obj.prop++; -z = --obj.prop; -z = obj.prop--; -z = obj.prop += arr[0]; -z = obj.prop -= arr[0]; -z = obj.prop *= arr[0]; -z = arr[0] /= obj.prop; -z = arr[0] %= obj.prop; -z = arr[0] **= obj.prop; -z = obj.prop |= arr[0]; -z = obj.prop &= arr[0]; -z = obj.prop ^= arr[0]; -z = obj.prop <<= arr[0]; -z = obj.prop >>= arr[0]; -z = obj.prop + (arr[0] += 7); -z = obj.prop += (arr[0] += 7); -z = obj.prop++ + (arr[0] += 7); -z = ++getObj().prop; -z = getObj().prop++; -z = --getObj().prop; -z = getObj().prop--; -z = getObj().prop += getArr()[getIndex()]; -z = getObj().prop -= getArr()[getIndex()]; -z = getObj().prop *= getArr()[getIndex()]; -z = getArr()[getIndex()] /= getObj().prop; -z = getArr()[getIndex()] %= getObj().prop; -z = getArr()[getIndex()] **= getObj().prop; -z = getObj().prop |= getArr()[getIndex()]; -z = getObj().prop &= getArr()[getIndex()]; -z = getObj().prop ^= getArr()[getIndex()]; -z = getObj().prop <<= getArr()[getIndex()]; -z = getObj().prop >>= getArr()[getIndex()]; -z = getObj().prop + (getArr()[getIndex()] += 7); -z = getObj().prop += (getArr()[getIndex()] += 7); -z = getObj().prop++ + (getArr()[getIndex()] += 7); -++getObj().arr[0]; -getObj().arr[0]++; -getObj().arr[getIndex()] += 13; -++arr2[0][getIndex()]; -arr2[0][getIndex()]++; -++arr2[getIndex()][0]; -arr2[getIndex()][0]++; -z = ++getObj().arr[0]; -z = getObj().arr[0]++; -z = getObj().arr[getIndex()] += 13; -z = ++arr2[0][getIndex()]; -z = arr2[0][getIndex()]++; -z = ++arr2[getIndex()][0]; -z = arr2[getIndex()][0]++; -z = x = arr2[0][getIndex()]; -z = getObj().arr[0] = x; -z = getObj().arr[0] = arr2[0][getIndex()]; diff --git a/test/translation/ts/classExtension1.ts b/test/translation/ts/classExtension1.ts index cf293483d..5df5bdeac 100644 --- a/test/translation/ts/classExtension1.ts +++ b/test/translation/ts/classExtension1.ts @@ -1,4 +1,4 @@ -/** !Extension */ +/** @extension */ class MyClass { public myFunction() {} } diff --git a/test/translation/ts/classExtension2.ts b/test/translation/ts/classExtension2.ts index 109160d97..158f16422 100644 --- a/test/translation/ts/classExtension2.ts +++ b/test/translation/ts/classExtension2.ts @@ -1,8 +1,8 @@ -/** !Extension */ +/** @extension */ class TestClass { } -/** !Extension */ +/** @extension */ class MyClass extends TestClass { public myFunction() {} } diff --git a/test/translation/ts/classExtension3.ts b/test/translation/ts/classExtension3.ts index 287c46d3f..3fa37f05e 100644 --- a/test/translation/ts/classExtension3.ts +++ b/test/translation/ts/classExtension3.ts @@ -1,9 +1,9 @@ -/** !Extension RenamedTestClass */ +/** @extension RenamedTestClass */ class TestClass { public myFunction() {} } -/** !Extension RenamedMyClass */ +/** @extension RenamedMyClass */ class MyClass extends TestClass { public myFunction() {} } diff --git a/test/translation/ts/classExtension4.ts b/test/translation/ts/classExtension4.ts index 2183c5610..8cb996079 100644 --- a/test/translation/ts/classExtension4.ts +++ b/test/translation/ts/classExtension4.ts @@ -1,4 +1,4 @@ -/** !Extension */ +/** @extension */ class MyClass { public test: string = "test"; private testP: string = "testP"; diff --git a/test/translation/ts/classPureAbstract.ts b/test/translation/ts/classPureAbstract.ts index c511f0de2..178c23b59 100644 --- a/test/translation/ts/classPureAbstract.ts +++ b/test/translation/ts/classPureAbstract.ts @@ -1,3 +1,3 @@ -/** !PureAbstract */ +/** @pureAbstract */ declare class ClassA {} class ClassB extends ClassA {} \ No newline at end of file diff --git a/test/translation/ts/enumMembersOnly.ts b/test/translation/ts/enumMembersOnly.ts index 1032bea82..9d384dc6c 100644 --- a/test/translation/ts/enumMembersOnly.ts +++ b/test/translation/ts/enumMembersOnly.ts @@ -1,9 +1,9 @@ -/** !CompileMembersOnly */ +/** @compileMembersOnly */ enum TestEnum { val1 = 0, val2 = 2, val3, - val4 = "bye" + val4 = "bye", } const a = TestEnum.val1; diff --git a/test/translation/ts/modulesNamespaceExportEnum.ts b/test/translation/ts/modulesNamespaceExportEnum.ts new file mode 100644 index 000000000..dd40d81cb --- /dev/null +++ b/test/translation/ts/modulesNamespaceExportEnum.ts @@ -0,0 +1,6 @@ +export namespace test { + export enum TestEnum { + foo = "foo", + bar = "bar", + } +} diff --git a/test/translation/ts/namespacePhantom.ts b/test/translation/ts/namespacePhantom.ts index b107d3387..c99b88e8d 100644 --- a/test/translation/ts/namespacePhantom.ts +++ b/test/translation/ts/namespacePhantom.ts @@ -1,4 +1,4 @@ -/** !Phantom */ +/** @phantom */ namespace myNamespace { function nsMember() {} } \ No newline at end of file diff --git a/test/translation/ts/tupleReturn.ts b/test/translation/ts/tupleReturn.ts index 86fd32e97..0d2936071 100644 --- a/test/translation/ts/tupleReturn.ts +++ b/test/translation/ts/tupleReturn.ts @@ -1,4 +1,4 @@ -/** !TupleReturn */ +/** @tupleReturn */ function tupleReturn(): [number, string] { return [0, "foobar"]; } @@ -16,19 +16,19 @@ e = tupleReturn(); f = noTupleReturn(); foo(tupleReturn()); foo(noTupleReturn()); -/** !TupleReturn */ +/** @tupleReturn */ function tupleReturnFromVar(): [number, string] { const r: [number, string] = [1, "baz"]; return r; } -/** !TupleReturn */ +/** @tupleReturn */ function tupleReturnForward(): [number, string] { return tupleReturn(); } function tupleNoForward(): [number, string] { return tupleReturn(); } -/** !TupleReturn */ +/** @tupleReturn */ function tupleReturnUnpack(): [number, string] { return tupleNoForward(); } diff --git a/test/unit/array.spec.ts b/test/unit/array.spec.ts index bca94494a..cb7a4c43c 100644 --- a/test/unit/array.spec.ts +++ b/test/unit/array.spec.ts @@ -38,4 +38,17 @@ export class ArrayTests { const result = util.executeLua(lua); Expect(result).toBe(5); } + + @Test("Derived array access") + public derivedArrayAccess(): void { + const lua = `local arr = {firstElement=function(self) return self[1]; end};` + + util.transpileString( + `interface CustomArray extends Array{ firstElement():number; }; + declare const arr: CustomArray; + arr[0] = 3; + return arr.firstElement();` + ); + const result = util.executeLua(lua); + Expect(result).toBe(3); + } } diff --git a/test/unit/assignmentDestructuring.spec.ts b/test/unit/assignmentDestructuring.spec.ts index 650e13024..bbe555adb 100644 --- a/test/unit/assignmentDestructuring.spec.ts +++ b/test/unit/assignmentDestructuring.spec.ts @@ -9,7 +9,7 @@ export class AssignmentDestructuringTests { let [a, b] = myFunc();`; @Test("Assignment destructuring [5.1]") - public assignmentDestructuring51() { + public assignmentDestructuring51(): void { // Transpile const lua = util.transpileString( this.assignmentDestruturingTs, {luaTarget: LuaTarget.Lua51, luaLibImport: "none"} @@ -19,7 +19,7 @@ export class AssignmentDestructuringTests { } @Test("Assignment destructuring [5.2]") - public tupleDestructing52() { + public tupleDestructing52(): void { // Transpile const lua = util.transpileString( this.assignmentDestruturingTs, {luaTarget: LuaTarget.Lua52, luaLibImport: "none"} @@ -27,4 +27,14 @@ export class AssignmentDestructuringTests { // Assert Expect(lua).toBe(`local a,b=table.unpack(myFunc());`); } + + @Test("Assignment destructuring [JIT]") + public assignmentDestructuringJIT(): void { + // Transpile + const lua = util.transpileString( + this.assignmentDestruturingTs, {luaTarget: LuaTarget.LuaJIT, luaLibImport: "none"} + ); + // Assert + Expect(lua).toBe(`local a,b=unpack(myFunc());`); + } } diff --git a/test/unit/assignments.spec.ts b/test/unit/assignments.spec.ts index c688d5e9f..1d8ef2358 100644 --- a/test/unit/assignments.spec.ts +++ b/test/unit/assignments.spec.ts @@ -93,7 +93,7 @@ export class AssignmentTests { @Test("TupleReturn assignment") public tupleReturnFunction(): void { - const code = `/** !TupleReturn */\n` + const code = `/** @tupleReturn */\n` + `declare function abc() { return [1,2,3]; }\n` + `let [a,b] = abc();`; @@ -103,7 +103,7 @@ export class AssignmentTests { @Test("TupleReturn Single assignment") public tupleReturnSingleAssignment(): void { - const code = `/** !TupleReturn */\n` + const code = `/** @tupleReturn */\n` + `declare function abc(): [number, string]; }\n` + `let a = abc();` + `a = abc();`; @@ -115,7 +115,7 @@ export class AssignmentTests { @Test("TupleReturn interface assignment") public tupleReturnInterface(): void { const code = `interface def {\n` - + `/** !TupleReturn */\n` + + `/** @tupleReturn */\n` + `abc();\n` + `} declare const jkl : def;\n` + `let [a,b] = jkl.abc();`; @@ -127,7 +127,7 @@ export class AssignmentTests { @Test("TupleReturn namespace assignment") public tupleReturnNameSpace(): void { const code = `declare namespace def {\n` - + `/** !TupleReturn */\n` + + `/** @tupleReturn */\n` + `function abc() {}\n` + `}\n` + `let [a,b] = def.abc();`; @@ -139,7 +139,7 @@ export class AssignmentTests { @Test("TupleReturn method assignment") public tupleReturnMethod(): void { const code = `declare class def {\n` - + `/** !TupleReturn */\n` + + `/** @tupleReturn */\n` + `abc() { return [1,2,3]; }\n` + `} const jkl = new def();\n` + `let [a,b] = jkl.abc();`; @@ -150,7 +150,7 @@ export class AssignmentTests { @Test("TupleReturn functional") public tupleReturnFunctional(): void { - const code = `/** !TupleReturn */ + const code = `/** @tupleReturn */ function abc(): [number, string] { return [3, "a"]; } const [a, b] = abc(); return b + a;`; @@ -164,7 +164,7 @@ export class AssignmentTests { @Test("TupleReturn single") public tupleReturnSingle(): void { - const code = `/** !TupleReturn */ + const code = `/** @tupleReturn */ function abc(): [number, string] { return [3, "a"]; } const res = abc(); return res.length`; @@ -178,7 +178,7 @@ export class AssignmentTests { @Test("TupleReturn in expression") public tupleReturnInExpression(): void { - const code = `/** !TupleReturn */ + const code = `/** @tupleReturn */ function abc(): [number, string] { return [3, "a"]; } return abc()[1] + abc()[0];`; diff --git a/test/unit/class.spec.ts b/test/unit/class.spec.ts index d3655034f..bc83f8681 100644 --- a/test/unit/class.spec.ts +++ b/test/unit/class.spec.ts @@ -44,7 +44,7 @@ export class ClassTests { @Test("ClassConstructorAssignment") public classConstructorAssignment(): void { - // Transpile + // Transpile const lua = util.transpileString( `class a { constructor(public field: number) {} } return new a(4).field;` @@ -57,6 +57,26 @@ export class ClassTests { Expect(result).toBe(4); } + @Test("ClassConstructorDefaultParameter") + public classConstructorDefaultParameter(): void { + const result = util.transpileAndExecute( + `class a { public field: number; constructor(f: number = 3) { this.field = f; } } + return new a().field;` + ); + + Expect(result).toBe(3); + } + + @Test("ClassConstructorAssignmentDefault") + public classConstructorAssignmentParameterDefault(): void { + const result = util.transpileAndExecute( + `class a { constructor(public field: number = 3) { } } + return new a().field;` + ); + + Expect(result).toBe(3); + } + @Test("ClassNewNoBrackets") public classNewNoBrackets(): void { // Transpile @@ -107,6 +127,59 @@ export class ClassTests { Expect(result).toBe(4); } + @Test("SubclassDefaultConstructor") + public subclassDefaultConstructor(): void { + const result = util.transpileAndExecute( + `class a { + field: number; + constructor(field: number) { + this.field = field; + } + } + class b extends a {} + return new b(10).field;` + ); + + Expect(result).toBe(10); + } + + @Test("SubsubclassDefaultConstructor") + public subsubclassDefaultConstructor(): void { + const result = util.transpileAndExecute( + `class a { + field: number; + constructor(field: number) { + this.field = field; + } + } + class b extends a {} + class c extends b {} + return new c(10).field;` + ); + + Expect(result).toBe(10); + } + + @Test("SubclassConstructor") + public subclassConstructor(): void { + const result = util.transpileAndExecute( + `class a { + field: number; + constructor(field: number) { + this.field = field; + } + } + class b extends a { + constructor(field: number) { + super(field + 1); + } + } + return new b(10).field;` + ); + + Expect(result).toBe(11); + } + @Test("classSuper") public classSuper(): void { // Transpile diff --git a/test/unit/conditionals.spec.ts b/test/unit/conditionals.spec.ts index 3e56620ca..e48fd962f 100644 --- a/test/unit/conditionals.spec.ts +++ b/test/unit/conditionals.spec.ts @@ -1,4 +1,6 @@ import { Expect, Test, TestCase } from "alsatian"; +import { TranspileError } from "../../src/Errors"; +import { LuaTarget } from "../../src/Transpiler"; import * as util from "../src/util"; export class LuaConditionalsTests { @@ -326,4 +328,10 @@ export class LuaConditionalsTests { Expect(result).toBe(5); } + + @Test("switch not allowed in 5.1") + public switchThrow51(): void { + Expect( () => util.transpileString(`switch ("abc") {}`, {luaTarget: LuaTarget.Lua51})) + .toThrowError(TranspileError, "Switch statements is/are not supported for target Lua 5.1."); + } } diff --git a/test/unit/decoratorCustomConstructor.spec.ts b/test/unit/decoratorCustomConstructor.spec.ts index b9e4c7242..5433b2f4f 100644 --- a/test/unit/decoratorCustomConstructor.spec.ts +++ b/test/unit/decoratorCustomConstructor.spec.ts @@ -9,7 +9,7 @@ export class DecoratorCustomConstructor { public customCreate(): void { // Transpile const lua = util.transpileString( - `/** !CustomConstructor Point2DCreate */ + `/** @customConstructor Point2DCreate */ class Point2D { x: number; y: number; @@ -29,7 +29,7 @@ export class DecoratorCustomConstructor { public incorrectUsage(): void { Expect(() => { util.transpileString( - `/** !CustomConstructor */ + `/** @customConstructor */ class Point2D { x: number; y: number; diff --git a/test/unit/decoratorMetaExtension.spec.ts b/test/unit/decoratorMetaExtension.spec.ts index d29f51467..eddba794b 100644 --- a/test/unit/decoratorMetaExtension.spec.ts +++ b/test/unit/decoratorMetaExtension.spec.ts @@ -14,7 +14,7 @@ export class DecoratorMetaExtension { declare namespace debug { function getregistry(): any; } - /** !MetaExtension */ + /** @metaExtension */ class LoadedExt extends _LOADED { public static test() { return 5; @@ -33,7 +33,7 @@ export class DecoratorMetaExtension { Expect(() => { util.transpileString( ` - /** !MetaExtension */ + /** @metaExtension */ class LoadedExt { public static test() { return 5; @@ -51,7 +51,7 @@ export class DecoratorMetaExtension { util.transpileString( ` declare class _LOADED; - /** !MetaExtension */ + /** @metaExtension */ class Ext extends _LOADED { } const e = new Ext(); diff --git a/test/unit/enum.spec.ts b/test/unit/enum.spec.ts index 1ece6b740..ee7e5548e 100644 --- a/test/unit/enum.spec.ts +++ b/test/unit/enum.spec.ts @@ -4,6 +4,63 @@ import * as util from "../src/util"; import { TranspileError } from "../../src/Errors"; export class EnumTests { + @Test("Declare const enum") + public declareConstEnum(): void { + const testCode = ` + declare const enum TestEnum { + MEMBER_ONE = "test", + MEMBER_TWO = "test2" + } + + const valueOne = TestEnum.MEMBER_ONE; + `; + + Expect(util.transpileString(testCode)).toBe(`local valueOne = "test";`); + } + + @Test("Const enum") + public constEnum(): void { + const testCode = ` + const enum TestEnum { + MEMBER_ONE = "test", + MEMBER_TWO = "test2" + } + + const valueOne = TestEnum.MEMBER_ONE; + `; + + Expect(util.transpileString(testCode)).toBe(`local valueOne = "test";`); + } + + @Test("Const enum without initializer") + public constEnumNoInitializer(): void { + const testCode = ` + const enum TestEnum { + MEMBER_ONE, + MEMBER_TWO + } + + const valueOne = TestEnum.MEMBER_ONE; + `; + + Expect(util.transpileString(testCode)).toBe(`local valueOne = 0;`); + } + + @Test("Const enum without initializer in some values") + public constEnumNoInitializerInSomeValues(): void { + const testCode = ` + const enum TestEnum { + MEMBER_ONE = 3, + MEMBER_TWO, + MEMBER_THREE = 5 + } + + const valueOne = TestEnum.MEMBER_TWO; + `; + + Expect(util.transpileString(testCode)).toBe(`local valueOne = 4;`); + } + @Test("Invalid heterogeneous enum") public invalidHeterogeneousEnum(): void { // Transpile & Assert diff --git a/test/unit/error.spec.ts b/test/unit/error.spec.ts index f3f737a09..da0e59473 100644 --- a/test/unit/error.spec.ts +++ b/test/unit/error.spec.ts @@ -24,4 +24,55 @@ export class LuaErrorTests { ); }).toThrowError(TranspileError, "Invalid throw expression, only strings can be thrown."); } + + @TestCase(0, "A") + @TestCase(1, "B") + @TestCase(2, "C") + @Test("re-throw") + public reThrow(i: number, expected: any): void { + const source = + `const i = ${i}; + function foo() { + try { + try { + if (i === 0) { throw "z"; } + } catch (e) { + throw "a"; + } finally { + if (i === 1) { throw "b"; } + } + } catch (e) { + throw (e as string).toUpperCase(); + } finally { + throw "C"; + } + } + let result = "x"; + try { + foo(); + } catch (e) { + result = (e as string)[(e as string).length - 1]; + } + return result;`; + const result = util.transpileAndExecute(source); + Expect(result).toBe(expected); + } + + @Test("re-throw (no catch var)") + public reThrowWithoutCatchVar(): void { + const source = + `let result = "x"; + try { + try { + throw "y"; + } catch { + throw "z"; + } + } catch (e) { + result = (e as string)[(e as string).length - 1]; + } + return result;`; + const result = util.transpileAndExecute(source); + Expect(result).toBe("z"); + } } diff --git a/test/unit/expressions.spec.ts b/test/unit/expressions.spec.ts index 2fa26da68..6f9c2ba30 100644 --- a/test/unit/expressions.spec.ts +++ b/test/unit/expressions.spec.ts @@ -254,6 +254,39 @@ export class ExpressionTests { Expect(result).toBe(expected); } + @TestCase("inst.baseField", 7) + @TestCase("inst.field", 6) + @TestCase("inst.superField", 5) + @TestCase("inst.superBaseField", 4) + @Test("Inherited accessors") + public inheritedAccessors(expression: string, expected: any): void { + const source = `class MyBaseClass {` + + ` public _baseField: number;` + + ` public get baseField(): number { return this._baseField + 6; }` + + ` public set baseField(v: number) { this._baseField = v; }` + + `}` + + `class MyClass extends MyBaseClass {` + + ` public _field: number;` + + ` public get field(): number { return this._field + 4; }` + + ` public set field(v: number) { this._field = v; }` + + `}` + + `class MySuperClass extends MyClass {` + + ` public _superField: number;` + + ` public get superField(): number { return this._superField + 2; }` + + ` public set superField(v: number) { this._superField = v; }` + + ` public get superBaseField() { return this.baseField - 3; }` + + `}` + + `var inst = new MySuperClass();` + + `inst.baseField = 1;` + + `inst.field = 2;` + + `inst.superField = 3;` + + `return ${expression};`; + + const lua = util.transpileString(source); + const result = util.executeLua(lua); + Expect(result).toBe(expected); + } + @TestCase("i++", 10) @TestCase("i--", 10) @TestCase("++i", 11) @@ -324,7 +357,7 @@ export class ExpressionTests { `let x: [string, string] = ["x0", "x1"]; let y: [string, string] = ["y0", "y1"]; function t(): [string, string] { return ["t0", "t1"] }; - /** !TupleReturn */ + /** @tupleReturn */ function tr(): [string, string] { return ["tr0", "tr1"] }; const r = ${expression}; return \`\${r[0]},\${r[1]}\``); diff --git a/test/unit/loops.spec.ts b/test/unit/loops.spec.ts index 007127d33..4d6d6e985 100644 --- a/test/unit/loops.spec.ts +++ b/test/unit/loops.spec.ts @@ -286,6 +286,26 @@ export class LuaLoopTests { Expect(result).toBe(JSON.stringify(expected)); } + @TestCase([[1, 2], [2, 3], [3, 4]], [3, 5, 7]) + @Test("forof destructing") + public forofDestructing(inp: number[][], expected: any): void { + // Transpile + const lua = util.transpileString( + `let objTest = ${JSON.stringify(inp)}; + let arrResultTest = []; + for (let [a,b] of objTest) { + arrResultTest.push(a + b) + } + return JSONStringify(arrResultTest);` + ); + + // Execute + const result = util.executeLua(lua); + + // Assert + Expect(result).toBe(JSON.stringify(expected)); + } + @TestCase([0, 1, 2, 3, 4], [0, 0, 2, 0, 4]) @Test("forof with continue") public forofWithContinue(inp: number[], expected: number[]): void { diff --git a/test/unit/modules.spec.ts b/test/unit/modules.spec.ts index 62187e060..7d2509376 100644 --- a/test/unit/modules.spec.ts +++ b/test/unit/modules.spec.ts @@ -23,15 +23,6 @@ export class LuaModuleTests { Expect(lua.startsWith(`require("lualib_bundle")`)); } - @Test("lualibRequireNoUses") - public lualibRequireNoUses(): void { - // Transpile - const lua = util.transpileString(``, { luaLibImport: LuaLibImportKind.Require, luaTarget: LuaTarget.LuaJIT }); - - // Assert - Expect(lua).toBe(``); - } - @Test("lualibRequireAlways") public lualibRequireAlways(): void { // Transpile @@ -63,4 +54,16 @@ export class LuaModuleTests { Expect(result).toBe(3); } + + @TestCase(LuaLibImportKind.Inline) + @TestCase(LuaLibImportKind.None) + @TestCase(LuaLibImportKind.Require) + @Test("LuaLib no uses? No code") + public lualibNoUsesNoCode(impKind: LuaLibImportKind): void { + // Transpile + const lua = util.transpileString(``, { luaLibImport: impKind }); + + // Assert + Expect(lua).toBe(``); + } } diff --git a/test/unit/overloads.spec.ts b/test/unit/overloads.spec.ts index 69fa96cc1..e98fd6f0b 100644 --- a/test/unit/overloads.spec.ts +++ b/test/unit/overloads.spec.ts @@ -4,7 +4,7 @@ import * as util from "../src/util"; export class OverloadTests { @Test("overload function1") - public overloadFunction1() { + public overloadFunction1(): void { const lua = util.transpileString( `function abc(def: number): string; function abc(def: string): string; @@ -23,7 +23,7 @@ export class OverloadTests { } @Test("overload function2") - public overloadFunction2() { + public overloadFunction2(): void { const lua = util.transpileString( `function abc(def: number): string; function abc(def: string): string; @@ -42,7 +42,7 @@ export class OverloadTests { } @Test("overload method1") - public overloadMethod1() { + public overloadMethod1(): void { const lua = util.transpileString( `class myclass { static abc(def: number): string; @@ -63,7 +63,7 @@ export class OverloadTests { } @Test("overload method2") - public overloadMethod2() { + public overloadMethod2(): void { const lua = util.transpileString( `class myclass { static abc(def: number): string; @@ -82,4 +82,54 @@ export class OverloadTests { Expect(result).toBe("ghj"); } + + @Test("constructor1") + public constructor1(): void { + const lua = util.transpileString( + `class myclass { + num: number; + str: string; + + constructor(def: number): string; + constructor(def: string): string; + constructor(def: number | string): string { + if (typeof def == "number") { + this.num = def; + } else { + this.str = def; + } + } + } + const inst = new myclass(3); + return inst.num`); + + const result = util.executeLua(lua); + + Expect(result).toBe(3); + } + + @Test("constructor2") + public constructor2(): void { + const lua = util.transpileString( + `class myclass { + num: number; + str: string; + + constructor(def: number): string; + constructor(def: string): string; + constructor(def: number | string): string { + if (typeof def == "number") { + this.num = def; + } else { + this.str = def; + } + } + } + const inst = new myclass("ghj"); + return inst.str`); + + const result = util.executeLua(lua); + + Expect(result).toBe("ghj"); + } } diff --git a/test/unit/spreadElement.spec.ts b/test/unit/spreadElement.spec.ts index 50bf8f2dc..effd3d846 100644 --- a/test/unit/spreadElement.spec.ts +++ b/test/unit/spreadElement.spec.ts @@ -21,4 +21,20 @@ export class SpreadElementTest { const lua = util.transpileString(`[].push(...${JSON.stringify([1, 2, 3])});`, {luaTarget: LuaTarget.Lua51}); Expect(lua).toBe("__TS__ArrayPush({}, unpack({1,2,3}));"); } + + @Test("Spread Element Lua 5.2") + public spreadElement52() { + const lua = util.transpileString(`[...[0, 1, 2]]`, {luaTarget: LuaTarget.Lua52, luaLibImport: "none"}); + Expect(lua).toBe("{table.unpack({0,1,2})};"); + } + @Test("Spread Element Lua 5.3") + public spreadElement53() { + const lua = util.transpileString(`[...[0, 1, 2]]`, {luaTarget: LuaTarget.Lua53, luaLibImport: "none"}); + Expect(lua).toBe("{table.unpack({0,1,2})};"); + } + @Test("Spread Element Lua JIT") + public spreadElementJIT() { + const lua = util.transpileString(`[...[0, 1, 2]]`, {luaTarget: LuaTarget.LuaJIT, luaLibImport: "none"}); + Expect(lua).toBe("{unpack({0,1,2})};"); + } } diff --git a/test/unit/tshelper.spec.ts b/test/unit/tshelper.spec.ts index 2a14d34f2..774babd93 100644 --- a/test/unit/tshelper.spec.ts +++ b/test/unit/tshelper.spec.ts @@ -1,7 +1,10 @@ +import { Expect, Test, TestCase } from "alsatian"; +import { TSHelper as tsHelper } from "../../src/TSHelper"; + import * as ts from "typescript"; +import * as util from "../src/util"; -import { Expect, FocusTest, IgnoreTest, Test, TestCase } from "alsatian"; -import { TSHelper as tsEx } from "../../src/TSHelper"; +import { DecoratorKind } from "../../src/Decorator"; enum TestEnum { testA = 1, @@ -15,8 +18,8 @@ export class TSHelperTests { @TestCase(-1, "unknown") @TestCase(TestEnum.testA | TestEnum.testB, "unknown") @Test("EnumName") - public testEnumName(inp, expected) { - const result = tsEx.enumName(inp, TestEnum); + public testEnumName(inp, expected): void { + const result = tsHelper.enumName(inp, TestEnum); Expect(result).toEqual(expected); } @@ -26,14 +29,132 @@ export class TSHelperTests { @TestCase(TestEnum.testA | TestEnum.testC, ["testA", "testC"]) @TestCase(TestEnum.testA | TestEnum.testB | TestEnum.testC, ["testA", "testB", "testC"]) @Test("EnumNames") - public testEnumNames(inp, expected) { - const result = tsEx.enumNames(inp, TestEnum); + public testEnumNames(inp, expected): void { + const result = tsHelper.enumNames(inp, TestEnum); Expect(result).toEqual(expected); } @Test("IsFileModuleNull") - public isFileModuleNull() { - Expect(tsEx.isFileModule(null)).toEqual(false); + public isFileModuleNull(): void { + Expect(tsHelper.isFileModule(null)).toEqual(false); + } + + @Test("GetCustomDecorators single") + public GetCustomDecoratorsSingle(): void { + const source = `/** @compileMembersOnly */ + enum TestEnum { + val1 = 0, + val2 = 2, + val3, + val4 = "bye", + } + + const a = TestEnum.val1;`; + + const [sourceFile, typeChecker] = util.parseTypeScript(source); + const identifier = util.findFirstChild(sourceFile, ts.isIdentifier); + const enumType = typeChecker.getTypeAtLocation(identifier); + + const decorators = tsHelper.getCustomDecorators(enumType, typeChecker); + + Expect(decorators.size).toBe(1); + Expect(decorators.has(DecoratorKind.CompileMembersOnly)).toBeTruthy(); + } + + @Test("GetCustomDecorators multiple") + public GetCustomDecoratorsMultiple(): void { + const source = `/** @compileMembersOnly + * @Phantom */ + enum TestEnum { + val1 = 0, + val2 = 2, + val3, + val4 = "bye", + } + + const a = TestEnum.val1;`; + + const [sourceFile, typeChecker] = util.parseTypeScript(source); + const identifier = util.findFirstChild(sourceFile, ts.isIdentifier); + const enumType = typeChecker.getTypeAtLocation(identifier); + + const decorators = tsHelper.getCustomDecorators(enumType, typeChecker); + + Expect(decorators.size).toBe(2); + Expect(decorators.has(DecoratorKind.CompileMembersOnly)).toBeTruthy(); + Expect(decorators.has(DecoratorKind.Phantom)).toBeTruthy(); + } + + @Test("GetCustomDecorators single jsdoc") + public GetCustomDecoratorsSingleJSDoc(): void { + const source = `/** @compileMembersOnly */ + enum TestEnum { + val1 = 0, + val2 = 2, + val3, + val4 = "bye", + } + + const a = TestEnum.val1;`; + + const [sourceFile, typeChecker] = util.parseTypeScript(source); + const identifier = util.findFirstChild(sourceFile, ts.isIdentifier); + const enumType = typeChecker.getTypeAtLocation(identifier); + + const decorators = tsHelper.getCustomDecorators(enumType, typeChecker); + + Expect(decorators.size).toBe(1); + Expect(decorators.has(DecoratorKind.CompileMembersOnly)).toBeTruthy(); + } + + @Test("GetCustomDecorators multiple jsdoc") + public GetCustomDecoratorsMultipleJSDoc(): void { + const source = `/** @phantom + * @CompileMembersOnly */ + enum TestEnum { + val1 = 0, + val2 = 2, + val3, + val4 = "bye", + } + + const a = TestEnum.val1;`; + + const [sourceFile, typeChecker] = util.parseTypeScript(source); + const identifier = util.findFirstChild(sourceFile, ts.isIdentifier); + const enumType = typeChecker.getTypeAtLocation(identifier); + + const decorators = tsHelper.getCustomDecorators(enumType, typeChecker); + + Expect(decorators.size).toBe(2); + Expect(decorators.has(DecoratorKind.Phantom)).toBeTruthy(); + Expect(decorators.has(DecoratorKind.CompileMembersOnly)).toBeTruthy(); + } + + @Test("GetCustomDecorators multiple default jsdoc") + public GetCustomDecoratorsMultipleDefaultJSDoc(): void { + const source = `/** + * @description abc + * @phantom + * @compileMembersOnly */ + enum TestEnum { + val1 = 0, + val2 = 2, + val3, + val4 = "bye", + } + + const a = TestEnum.val1;`; + + const [sourceFile, typeChecker] = util.parseTypeScript(source); + const identifier = util.findFirstChild(sourceFile, ts.isIdentifier); + const enumType = typeChecker.getTypeAtLocation(identifier); + + const decorators = tsHelper.getCustomDecorators(enumType, typeChecker); + + Expect(decorators.size).toBe(2); + Expect(decorators.has(DecoratorKind.Phantom)).toBeTruthy(); + Expect(decorators.has(DecoratorKind.CompileMembersOnly)).toBeTruthy(); } } diff --git a/test/unit/tuples.spec.ts b/test/unit/tuples.spec.ts index 067776bd5..16bef9922 100644 --- a/test/unit/tuples.spec.ts +++ b/test/unit/tuples.spec.ts @@ -82,7 +82,7 @@ export class TupleTests { public tupleDestruct(): void { // Transpile const lua = util.transpileString( - `function tuple(): [number, number, number] { return [3,5,1]; }\n + `function tuple(): [number, number, number] { return [3,5,1]; } const [a,b,c] = tuple(); return b;` ); @@ -113,8 +113,8 @@ export class TupleTests { public tupleReturnAccess(): void { // Transpile const lua = util.transpileString( - `/** !TupleReturn */\n - function tuple(): [number, number, number] { return [3,5,1]; }\n + `/** @tupleReturn */ + function tuple(): [number, number, number] { return [3,5,1]; } return tuple()[2];` ); @@ -129,8 +129,8 @@ export class TupleTests { public tupleReturnDestructDeclaration(): void { // Transpile const lua = util.transpileString( - `/** !TupleReturn */\n - function tuple(): [number, number, number] { return [3,5,1]; }\n + `/** @tupleReturn */ + function tuple(): [number, number, number] { return [3,5,1]; } const [a,b,c] = tuple(); return b;` ); @@ -146,8 +146,8 @@ export class TupleTests { public tupleReturnDestructAssignment(): void { // Transpile const lua = util.transpileString( - `/** !TupleReturn */\n - function tuple(): [number, number] { return [3,6]; }\n + `/** @tupleReturn */ + function tuple(): [number, number] { return [3,6]; } const [a,b] = [1,2]; [b,a] = tuple(); return a - b;` @@ -164,10 +164,10 @@ export class TupleTests { public tupleStaticMethodReturnDestruct(): void { // Transpile const lua = util.transpileString( - `class Test {\n - /** !TupleReturn */\n - static tuple(): [number, number, number] { return [3,5,1]; }\n - }\n + `class Test { + /** @tupleReturn */ + static tuple(): [number, number, number] { return [3,5,1]; } + } const [a,b,c] = Test.tuple(); return b;` ); @@ -183,10 +183,10 @@ export class TupleTests { public tupleMethodNonStaticReturnDestruct(): void { // Transpile const lua = util.transpileString( - `class Test {\n - /** !TupleReturn */\n - tuple(): [number, number, number] { return [3,5,1]; }\n - }\n + `class Test { + /** @tupleReturn */ + tuple(): [number, number, number] { return [3,5,1]; } + } const t = new Test(); const [a,b,c] = t.tuple(); return b;`