Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b8eee68
LuaJIT target in help now is uppercased
ark120202 May 5, 2019
4bc488d
Unsupported for target error message now correctly formats `LuaJIT`
ark120202 May 5, 2019
220481d
Remove some unused helpers
ark120202 May 5, 2019
f7ce488
Specify only esnext lib in options
ark120202 May 5, 2019
6e79372
Add lib to tsconfig and remove browser global `name` usage
ark120202 May 5, 2019
9f7ff5d
Enable noUnusedLocals and noUnusedParameters
ark120202 May 5, 2019
aa32a5c
Fix `Function expression type inference in constructor` test
ark120202 May 5, 2019
54c1c54
Move lua types in lualib to declarations directory
ark120202 May 6, 2019
c5c1e03
Remove unused string.gmatch declaration
ark120202 May 6, 2019
6f2159d
Fix expectToBeDefined not checking for null
ark120202 May 6, 2019
073076a
Improve toHaveDiagnostics message
ark120202 May 6, 2019
95ffe2c
Declare correct return type for custom jest matchers
ark120202 May 6, 2019
4805fe0
Rename IdentifierOrTableIndexExpression to LeftHandSideExpression
ark120202 May 6, 2019
a5140df
Update dependencies
ark120202 May 6, 2019
a75b856
Remove unused rimraf dependency
ark120202 May 6, 2019
5c3dc81
Run CI on lowest supported node version
ark120202 May 6, 2019
757c3ea
Upgrade npm on appveyor
ark120202 May 6, 2019
a916904
Merge remote-tracking branch 'upstream/master' into small-improvements
ark120202 May 6, 2019
4737a33
Add tsconfig to lualib
ark120202 May 6, 2019
dcbd1b9
Check diagnostics of lualib
ark120202 May 6, 2019
b0b3f10
Rename some variables in Map and Set to match decloration files
ark120202 May 6, 2019
392caad
Use TypeScript 3.4 readonly array literals syntax
ark120202 May 6, 2019
2606809
Simplify `expression + 1` for numeric literals
ark120202 May 6, 2019
456ffdb
Simplify expression - 1 + 1
ark120202 May 13, 2019
2e076a1
Rename LeftHandSideExpression to AssignmentLeftHandSideExpression
ark120202 May 17, 2019
4cef77b
Add generic and literal array form tests
ark120202 May 17, 2019
267803d
Merge remote-tracking branch 'upstream/master' into small-improvements
ark120202 May 17, 2019
1d42195
Fix lint warning from tslint version upgrade
ark120202 May 17, 2019
9f15f21
Change lualib tslint command to use project
ark120202 May 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- stable
node_js: "8.5.0"

script:
- npm run build
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ Changelog can be found in [CHANGELOG.md](https://github.com/TypeScriptToLua/Type
{
"compilerOptions": {
"target": "esnext",
"lib": ["es2015", "es2016", "es2017", "es2018", "esnext"],
"lib": ["esnext"],
"strict": true
},
"tstl": {
"luaTarget": "JIT"
"luaTarget": "JIT"
}
}
```
Expand Down
8 changes: 5 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test against the latest version of this Node.js version
environment:
nodejs_version: "8"
nodejs_version: "8.5.0"

# Do not build feature branch with open Pull Requests
skip_branch_with_pr: true
Expand All @@ -13,15 +13,17 @@ cache:
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install modules
# Upgrade npm
- npm install --global npm@6
# Install modules
- npm ci

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
# Run tests
- npm run build
- npm test

Expand Down
24 changes: 6 additions & 18 deletions build_lualib.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
import * as fs from "fs";
import * as glob from "glob";
import * as path from "path";
import * as ts from "typescript";
import * as tstl from "./src";
import { LuaLib } from "./src/LuaLib";

const options: tstl.CompilerOptions = {
skipLibCheck: true,
types: [],
target: ts.ScriptTarget.ESNext,
lib: ["lib.esnext.d.ts"],

outDir: path.join(__dirname, "./dist/lualib"),
rootDir: path.join(__dirname, "./src/lualib"),

luaLibImport: tstl.LuaLibImportKind.None,
luaTarget: tstl.LuaTarget.Lua51,
noHeader: true,
};

// TODO: Check diagnostics
const { emitResult } = tstl.transpileFiles(glob.sync("./src/lualib/**/*.ts"), options);
const configFileName = path.resolve(__dirname, "src/lualib/tsconfig.json");
const { emitResult, diagnostics } = tstl.transpileProject(configFileName);
emitResult.forEach(({ name, text }) => ts.sys.writeFile(name, text));

const bundlePath = path.join(__dirname, "./dist/lualib/lualib_bundle.lua");
const reportDiagnostic = tstl.createDiagnosticReporter(true);
diagnostics.forEach(reportDiagnostic);

const bundlePath = path.join(__dirname, "dist/lualib/lualib_bundle.lua");
if (fs.existsSync(bundlePath)) {
fs.unlinkSync(bundlePath);
}
Expand Down
4,561 changes: 3,649 additions & 912 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "jest",
"lint": "npm run lint:tslint && npm run lint:prettier",
"lint:prettier": "prettier --check **/*.{js,ts,yml,json} || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
"lint:tslint": "tslint -p . && tslint -p test && tslint src/lualib/*.ts",
"lint:tslint": "tslint -p . && tslint -p test && tslint -p src/lualib",
"fix:prettier": "prettier --check --write **/*.{js,ts,yml,json}",
"release-major": "npm version major",
"release-minor": "npm version minor",
Expand All @@ -40,20 +40,18 @@
},
"dependencies": {
"source-map": "^0.7.3",
"typescript": "^3.3.1"
"typescript": "^3.4.5"
},
"devDependencies": {
"@types/glob": "^5.0.35",
"@types/jest": "^24.0.11",
"@types/glob": "^7.1.1",
"@types/jest": "^24.0.12",
"@types/node": "^11.13.0",
"fengari": "^0.1.2",
"glob": "^7.1.2",
"jest": "^24.5.0",
"jest-circus": "^24.5.0",
"prettier": "^1.16.4",
"rimraf": "^2.6.3",
"ts-jest": "^24.0.0",
"fengari": "^0.1.4",
"jest": "^24.8.0",
"jest-circus": "^24.8.0",
"prettier": "^1.17.0",
"ts-jest": "^24.0.2",
"ts-node": "^7.0.0",
"tslint": "^5.10.0"
"tslint": "^5.16.0"
}
}
17 changes: 14 additions & 3 deletions src/CommandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,16 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
};
}

const normalizedValue = value.toLowerCase();
if (option.choices && !option.choices.includes(normalizedValue)) {
const enumValue = option.choices.find(c => c.toLowerCase() === value.toLowerCase());
if (enumValue === undefined) {
const optionChoices = option.choices.join(", ");
return {
value: undefined,
error: diagnostics.argumentForOptionMustBe(`--${option.name}`, optionChoices),
};
}

return { value: normalizedValue };
return { value: enumValue };
}
}
}
Expand All @@ -240,3 +240,14 @@ export function parseConfigFileWithSystem(

return updateParsedConfigFile(parsedConfigFile);
}

export function createDiagnosticReporter(pretty: boolean, system = ts.sys): ts.DiagnosticReporter {
const reporter: ts.DiagnosticReporter = (ts as any).createDiagnosticReporter(system, pretty);
return diagnostic => {
if (diagnostic.source === "typescript-to-lua") {
diagnostic = { ...diagnostic, code: ("TL" + diagnostic.code) as any };
}

reporter(diagnostic);
};
}
2 changes: 1 addition & 1 deletion src/CompilerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export enum LuaTarget {
Lua51 = "5.1",
Lua52 = "5.2",
Lua53 = "5.3",
LuaJIT = "jit",
LuaJIT = "JIT",
}
6 changes: 3 additions & 3 deletions src/LuaAST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export function createVariableDeclarationStatement(
// `test1, test2 = 12, 42`
export interface AssignmentStatement extends Statement {
kind: SyntaxKind.AssignmentStatement;
left: IdentifierOrTableIndexExpression[];
left: AssignmentLeftHandSideExpression[];
right: Expression[];
}

Expand All @@ -262,7 +262,7 @@ export function isAssignmentStatement(node: Node): node is AssignmentStatement {
}

export function createAssignmentStatement(
left: IdentifierOrTableIndexExpression | IdentifierOrTableIndexExpression[],
left: AssignmentLeftHandSideExpression | AssignmentLeftHandSideExpression[],
right?: Expression | Expression[],
tsOriginal?: ts.Node,
parent?: Node
Expand Down Expand Up @@ -874,7 +874,7 @@ export function createTableIndexExpression(
return expression;
}

export type IdentifierOrTableIndexExpression = Identifier | TableIndexExpression;
export type AssignmentLeftHandSideExpression = Identifier | TableIndexExpression;

export type FunctionDefinition = (VariableDeclarationStatement | AssignmentStatement) & {
right: [FunctionExpression];
Expand Down
Loading