Skip to content

Commit 75de99d

Browse files
committed
Merge branch 'master' into diagnostics
2 parents 9eaa4ad + c05029b commit 75de99d

File tree

13 files changed

+1634
-1937
lines changed

13 files changed

+1634
-1937
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ jobs:
3737
env:
3838
CI: true
3939
- if: matrix.os == 'ubuntu-latest'
40-
continue-on-error: true
41-
uses: codecov/codecov-action@v1.0.0
42-
with:
43-
token: ${{ secrets.CODECOV_TOKEN }}
40+
uses: codecov/codecov-action@v1

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- TypeScript has been updated to 3.8. See [release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html) for details.
6+
57
- Errors reported during transpilation now are created as TypeScript diagnostics, instead of being thrown as JavaScript errors. This makes TypeScriptToLua always try to generate valid code (even in presence of errors) and allows multiple errors to be reported in a single file:
68

79
<!-- prettier-ignore -->

package-lock.json

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

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@
3939
"node": ">=12.13.0"
4040
},
4141
"dependencies": {
42-
"resolve": "^1.13.1",
42+
"resolve": "^1.15.1",
4343
"source-map": "^0.7.3",
44-
"typescript": "^3.7.3"
44+
"typescript": "^3.8.3"
4545
},
4646
"devDependencies": {
47-
"@types/fs-extra": "^8.0.1",
47+
"@types/fs-extra": "^8.1.0",
4848
"@types/glob": "^7.1.1",
49-
"@types/jest": "^24.0.23",
50-
"@types/node": "^12.12.14",
51-
"@types/resolve": "0.0.8",
49+
"@types/jest": "^25.1.3",
50+
"@types/node": "^13.7.7",
51+
"@types/resolve": "1.14.0",
5252
"fengari": "^0.1.4",
5353
"fs-extra": "^8.1.0",
5454
"javascript-stringify": "^2.0.1",
55-
"jest": "^24.9.0",
56-
"jest-circus": "^24.9.0",
55+
"jest": "^25.1.0",
56+
"jest-circus": "^25.1.0",
5757
"prettier": "^1.19.1",
58-
"ts-jest": "^24.2.0",
59-
"ts-node": "^8.5.4",
60-
"tslint": "^5.20.1"
58+
"ts-jest": "^25.2.1",
59+
"ts-node": "^8.6.2",
60+
"tslint": "^6.0.0"
6161
}
6262
}

src/CompilerOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & {
2626
luaLibImport?: LuaLibImportKind;
2727
sourceMapTraceback?: boolean;
2828
plugins?: Array<ts.PluginImport | TransformerImport>;
29-
[option: string]: ts.CompilerOptions[string] | Array<ts.PluginImport | TransformerImport>;
29+
[option: string]: any;
3030
};
3131

3232
export enum LuaLibImportKind {

src/lualib/SourceMapTraceBack.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ function __TS__SourceMapTraceBack(this: void, fileName: string, sourceMap: { [li
77
if (globalThis.__TS__originalTraceback === undefined) {
88
globalThis.__TS__originalTraceback = debug.traceback;
99
debug.traceback = (thread, message, level) => {
10-
const trace = globalThis.__TS__originalTraceback(thread, message, level);
10+
let trace: string;
11+
if (thread === undefined && message === undefined && level === undefined) {
12+
trace = globalThis.__TS__originalTraceback();
13+
} else {
14+
trace = globalThis.__TS__originalTraceback(thread, message, level);
15+
}
1116

1217
if (typeof trace !== "string") {
1318
return trace;

src/transformation/visitors/binary-expression/destructuring-assignments.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ function transformSpreadAssignment(
261261
for (const property of properties) {
262262
if (
263263
(ts.isShorthandPropertyAssignment(property) || ts.isPropertyAssignment(property)) &&
264-
!ts.isComputedPropertyName(property.name)
264+
!ts.isComputedPropertyName(property.name) &&
265+
!ts.isPrivateIdentifier(property.name)
265266
) {
266267
const name = ts.isIdentifier(property.name)
267268
? lua.createStringLiteral(property.name.text)

src/transformation/visitors/call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function transformContextualCallExpression(
4646
transformedArguments: lua.Expression[]
4747
): lua.Expression {
4848
const left = ts.isCallExpression(node) ? node.expression : node.tag;
49-
if (ts.isPropertyAccessExpression(left) && isValidLuaIdentifier(left.name.text)) {
49+
if (ts.isPropertyAccessExpression(left) && ts.isIdentifier(left.name) && isValidLuaIdentifier(left.name.text)) {
5050
// table:name()
5151
const table = context.transformExpression(left.expression);
5252

src/transformation/visitors/function.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
wrapInTable,
1313
} from "../utils/lua-ast";
1414
import { peekScope, performHoisting, popScope, pushScope, Scope, ScopeType } from "../utils/scope";
15-
import { getSymbolIdOfSymbol } from "../utils/symbols";
1615
import { transformGeneratorFunctionBody } from "./generator";
1716
import { transformIdentifier } from "./identifier";
1817
import { transformBindingPattern } from "./variable-declaration";
@@ -215,9 +214,13 @@ export function transformFunctionLikeDeclaration(
215214
if (ts.isFunctionExpression(node) && node.name && scope.referencedSymbols) {
216215
const symbol = context.checker.getSymbolAtLocation(node.name);
217216
if (symbol) {
218-
const symbolId = getSymbolIdOfSymbol(context, symbol);
217+
// TODO: Not using symbol ids because of https://github.com/microsoft/TypeScript/issues/37131
218+
const isReferenced = [...scope.referencedSymbols].some(([, nodes]) =>
219+
nodes.some(n => context.checker.getSymbolAtLocation(n)?.valueDeclaration === symbol.valueDeclaration)
220+
);
221+
219222
// Only wrap if the name is actually referenced inside the function
220-
if (symbolId !== undefined && scope.referencedSymbols.has(symbolId)) {
223+
if (isReferenced) {
221224
const nameIdentifier = transformIdentifier(context, node.name);
222225
return createImmediatelyInvokedFunctionExpression(
223226
[lua.createVariableDeclarationStatement(nameIdentifier, functionExpression)],

src/transformation/visitors/literal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export function transformPropertyName(context: TransformationContext, node: ts.P
1616
return context.transformExpression(node.expression);
1717
} else if (ts.isIdentifier(node)) {
1818
return lua.createStringLiteral(node.text);
19+
} else if (ts.isPrivateIdentifier(node)) {
20+
throw new Error("PrivateIdentifier is not supported");
1921
} else {
2022
return context.transformExpression(node);
2123
}

0 commit comments

Comments
 (0)