Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,4 @@ jobs:
env:
CI: true
- if: matrix.os == 'ubuntu-latest'
continue-on-error: true
uses: codecov/codecov-action@v1.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new version of codecov action does not require a token, so CODECOV_TOKEN secret can be removed

uses: codecov/codecov-action@v1
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- TypeScript has been updated to 3.8. See [release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html) for details.

## 0.31.0

- **Breaking:** The old annotation syntax (`/* !varArg */`) **no longer works**, the only currently supported syntax is:
Expand Down
3,508 changes: 1,595 additions & 1,913 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@
"node": ">=12.13.0"
},
"dependencies": {
"resolve": "^1.13.1",
"resolve": "^1.15.1",
"source-map": "^0.7.3",
"typescript": "^3.7.3"
"typescript": "^3.8.3"
},
"devDependencies": {
"@types/fs-extra": "^8.0.1",
"@types/fs-extra": "^8.1.0",
"@types/glob": "^7.1.1",
"@types/jest": "^24.0.23",
"@types/node": "^12.12.14",
"@types/resolve": "0.0.8",
"@types/jest": "^25.1.3",
"@types/node": "^13.7.7",
"@types/resolve": "1.14.0",
"fengari": "^0.1.4",
"fs-extra": "^8.1.0",
"javascript-stringify": "^2.0.1",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"jest": "^25.1.0",
"jest-circus": "^25.1.0",
"prettier": "^1.19.1",
"ts-jest": "^24.2.0",
"ts-node": "^8.5.4",
"tslint": "^5.20.1"
"ts-jest": "^25.2.1",
"ts-node": "^8.6.2",
"tslint": "^6.0.0"
}
}
2 changes: 1 addition & 1 deletion src/CompilerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & {
luaLibImport?: LuaLibImportKind;
sourceMapTraceback?: boolean;
plugins?: Array<ts.PluginImport | TransformerImport>;
[option: string]: ts.CompilerOptions[string] | Array<ts.PluginImport | TransformerImport>;
[option: string]: any;
};

export enum LuaLibImportKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ function transformSpreadAssignment(
for (const property of properties) {
if (
(ts.isShorthandPropertyAssignment(property) || ts.isPropertyAssignment(property)) &&
!ts.isComputedPropertyName(property.name)
!ts.isComputedPropertyName(property.name) &&
!ts.isPrivateIdentifier(property.name)
) {
const name = ts.isIdentifier(property.name)
? lua.createStringLiteral(property.name.text)
Expand Down
1 change: 1 addition & 0 deletions src/transformation/visitors/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function transformContextualCallExpression(
const left = ts.isCallExpression(node) ? node.expression : node.tag;
if (
ts.isPropertyAccessExpression(left) &&
ts.isIdentifier(left.name) &&
!luaKeywords.has(left.name.text) &&
isValidLuaIdentifier(left.name.text)
) {
Expand Down
9 changes: 6 additions & 3 deletions src/transformation/visitors/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
wrapInTable,
} from "../utils/lua-ast";
import { peekScope, performHoisting, popScope, pushScope, Scope, ScopeType } from "../utils/scope";
import { getSymbolIdOfSymbol } from "../utils/symbols";
import { transformGeneratorFunctionBody } from "./generator";
import { transformIdentifier } from "./identifier";
import { transformBindingPattern } from "./variable-declaration";
Expand Down Expand Up @@ -215,9 +214,13 @@ export function transformFunctionLikeDeclaration(
if (ts.isFunctionExpression(node) && node.name && scope.referencedSymbols) {
const symbol = context.checker.getSymbolAtLocation(node.name);
if (symbol) {
const symbolId = getSymbolIdOfSymbol(context, symbol);
// TODO: Not using symbol ids because of https://github.com/microsoft/TypeScript/issues/37131
const isReferenced = [...scope.referencedSymbols].some(([, nodes]) =>
nodes.some(n => context.checker.getSymbolAtLocation(n)?.valueDeclaration === symbol.valueDeclaration)
);

// Only wrap if the name is actually referenced inside the function
if (symbolId !== undefined && scope.referencedSymbols.has(symbolId)) {
if (isReferenced) {
const nameIdentifier = transformIdentifier(context, node.name);
return createImmediatelyInvokedFunctionExpression(
[lua.createVariableDeclarationStatement(nameIdentifier, functionExpression)],
Expand Down
2 changes: 2 additions & 0 deletions src/transformation/visitors/literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export function transformPropertyName(context: TransformationContext, node: ts.P
return context.transformExpression(node.expression);
} else if (ts.isIdentifier(node)) {
return lua.createStringLiteral(node.text);
} else if (ts.isPrivateIdentifier(node)) {
throw new Error("PrivateIdentifier is not supported");
} else {
return context.transformExpression(node);
}
Expand Down
5 changes: 5 additions & 0 deletions src/transformation/visitors/modules/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export const transformExportDeclaration: FunctionVisitor<ts.ExportDeclaration> =
return undefined;
}

if (ts.isNamespaceExport(node.exportClause)) {
// export * as ns from "...";
throw new Error("NamespaceExport is not supported");
}

const exportSpecifiers = getExported(context, node.exportClause);

// export { ... };
Expand Down
2 changes: 1 addition & 1 deletion test/legacy-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function transpileStringsAsProject(
input: Record<string, string>,
options: tstl.CompilerOptions = {}
): tstl.TranspileResult {
const optionsWithDefaults = {
const optionsWithDefaults: tstl.CompilerOptions = {
luaTarget: tstl.LuaTarget.Lua53,
noHeader: true,
skipLibCheck: true,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/annotations/forRange.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ test("invalid non-ambient @forRange function", () => {
);
});

test.each([[1], [1, 2, 3, 4]])("invalid @forRange argument count", args => {
test.each([[1], [1, 2, 3, 4]])("invalid @forRange argument count", (...args) => {
const code = `
/** @forRange **/ declare function luaRange(...args: number[]): number[] { return []; }
for (const i of luaRange(${args})) {}`;
for (const i of luaRange(${util.formatCode(...args)})) {}`;

expect(() => util.transpileString(code)).toThrow(
InvalidForRangeCall(ts.createEmptyStatement(), "@forRange function must take 2 or 3 arguments.").message
Expand Down
2 changes: 1 addition & 1 deletion test/unit/builtins/string.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test.each([
["hello", "test", "bye"],
["hello", 42],
[42, "hello"],
])("string.concat[+] (%p)", (...elements) => {
])("string.concat[+] (%p)", (...elements: any[]) => {
util.testExpression(elements.map(e => util.formatCode(e)).join(" + ")).expectToMatchJsResult();
});

Expand Down