Skip to content

Commit 3f78471

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 7a3ef91 + 5a9fdfd commit 3f78471

31 files changed

Lines changed: 472 additions & 99 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
steps:
4848
- name: Lua Install
4949
run: sudo apt-get install lua5.3 luajit
50+
- name: Add Brew to Path (Required since Nov 2022)
51+
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
5052
- name: Glow Install
5153
run: brew install glow
5254
# Checkout master & commit

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 1.12.0
4+
5+
- Reworked how tstl detects and rewrites `require` statements during dependency resolution. This should reduce the amount of false-positive matches of require statements: require statements in string literals or comments should no longer be detected by tstl. This means require statements in string literals or comments can survive the transpiler without causing a 'could not resolve lua sources' error or getting rewritten into nonsense.
6+
- Now using `math.mod` for Lua 5.0 modulo operations.
7+
8+
## 1.11.0
9+
10+
- **[Breaking]** Upgraded TypeScript to 4.9.
11+
- `--tstlVerbose` now prints more resolver output when failing to resolve Lua sources.
12+
- Fixed a bug breaking default exported classes with unicode names
13+
- Relaxed conditions for the always-true warning to false positives.
14+
315
## 1.10.0
416

517
- **[Breaking]** Upgraded TypeScript to 4.8.

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jackmacwindows/typescript-to-lua",
3-
"version": "1.10.1",
3+
"version": "1.12.0",
44
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua! (With ComputerCraft support)",
55
"repository": "https://github.com/MCJack123/TypeScriptToLua",
66
"homepage": "https://typescripttolua.github.io/",
@@ -42,7 +42,7 @@
4242
"node": ">=16.10.0"
4343
},
4444
"peerDependencies": {
45-
"typescript": "~4.8.2"
45+
"typescript": "~4.9.3"
4646
},
4747
"dependencies": {
4848
"@typescript-to-lua/language-extensions": "1.0.0",
@@ -70,6 +70,6 @@
7070
"prettier": "^2.3.2",
7171
"ts-jest": "^28.0.8",
7272
"ts-node": "^10.9.1",
73-
"typescript": "~4.8.2"
73+
"typescript": "~4.9.3"
7474
}
7575
}

src/LuaAST.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// because we don't create the AST from text
66

77
import * as ts from "typescript";
8-
import { LuaLibFeature } from "./transformation/utils/lualib";
8+
import { LuaLibFeature } from "./LuaLib";
99
import { castArray } from "./utils";
1010

1111
export enum SyntaxKind {
@@ -816,6 +816,7 @@ export function createTableIndexExpression(
816816
}
817817

818818
export type AssignmentLeftHandSideExpression = Identifier | TableIndexExpression;
819+
819820
export function isAssignmentLeftHandSideExpression(node: Node): node is AssignmentLeftHandSideExpression {
820821
return isIdentifier(node) || isTableIndexExpression(node);
821822
}

src/LuaLib.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export enum LuaLibFeature {
5252
MathAtan2 = "MathAtan2",
5353
MathModf = "MathModf",
5454
MathSign = "MathSign",
55-
Modulo50 = "Modulo50",
5655
New = "New",
5756
Number = "Number",
5857
NumberIsFinite = "NumberIsFinite",

src/LuaPrinter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Mapping, SourceMapGenerator, SourceNode } from "source-map";
33
import * as ts from "typescript";
44
import { CompilerOptions, isBundleEnabled, LuaLibImportKind, LuaTarget } from "./CompilerOptions";
55
import * as lua from "./LuaAST";
6-
import { loadInlineLualibFeatures, LuaLibFeature, loadImportedLualibFeatures } from "./LuaLib";
6+
import { loadImportedLualibFeatures, loadInlineLualibFeatures, LuaLibFeature } from "./LuaLib";
77
import { isValidLuaIdentifier, shouldAllowUnicode } from "./transformation/utils/safe-names";
88
import { EmitHost, getEmitPath } from "./transpilation";
99
import { intersperse, normalizeSlashes } from "./utils";
@@ -900,9 +900,9 @@ export class LuaPrinter {
900900
map.addMapping(currentMapping);
901901
}
902902

903-
for (const chunk of sourceNode.children) {
903+
for (const chunk of sourceNode.children as SourceChunk[]) {
904904
if (typeof chunk === "string") {
905-
const lines = (chunk as string).split("\n");
905+
const lines = chunk.split("\n");
906906
if (lines.length > 1) {
907907
generatedLine += lines.length - 1;
908908
generatedColumn = 0;

src/cli/parse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function updateParsedCommandLine(parsedCommandLine: ts.ParsedCommandLine, args:
152152
if (!args[i].startsWith("-")) continue;
153153

154154
const isShorthand = !args[i].startsWith("--");
155-
const argumentName = args[i].substr(isShorthand ? 1 : 2);
155+
const argumentName = args[i].substring(isShorthand ? 1 : 2);
156156
const option = optionDeclarations.find(option => {
157157
if (option.name.toLowerCase() === argumentName.toLowerCase()) return true;
158158
if (isShorthand && option.aliases) {

src/lualib/Modulo50.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/lualib/ParseInt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export function __TS__ParseInt(this: void, numberString: string, base?: number):
1010
if (hexMatch) {
1111
base = 16;
1212
numberString = __TS__Match(hexMatch, "-")[0]
13-
? "-" + numberString.substr(hexMatch.length)
14-
: numberString.substr(hexMatch.length);
13+
? "-" + numberString.substring(hexMatch.length)
14+
: numberString.substring(hexMatch.length);
1515
}
1616
}
1717

@@ -22,7 +22,7 @@ export function __TS__ParseInt(this: void, numberString: string, base?: number):
2222

2323
// Calculate string match pattern to use
2424
const allowedDigits =
25-
base <= 10 ? parseIntBasePattern.substring(0, base) : parseIntBasePattern.substr(0, 10 + 2 * (base - 10));
25+
base <= 10 ? parseIntBasePattern.substring(0, base) : parseIntBasePattern.substring(0, 10 + 2 * (base - 10));
2626
const pattern = `^%s*(-?[${allowedDigits}]*)`;
2727

2828
// Try to parse with Lua tonumber

0 commit comments

Comments
 (0)