Skip to content

Commit 6b73c87

Browse files
committed
Fix TypeScript errors
1 parent 3dcf29f commit 6b73c87

File tree

8 files changed

+15
-6
lines changed

8 files changed

+15
-6
lines changed

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/transformation/visitors/binary-expression/destructuring-assignments.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ function transformSpreadAssignment(
252252
for (const property of properties) {
253253
if (
254254
(ts.isShorthandPropertyAssignment(property) || ts.isPropertyAssignment(property)) &&
255-
!ts.isComputedPropertyName(property.name)
255+
!ts.isComputedPropertyName(property.name) &&
256+
!ts.isPrivateIdentifier(property.name)
256257
) {
257258
const name = ts.isIdentifier(property.name)
258259
? lua.createStringLiteral(property.name.text)

src/transformation/visitors/call.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function transformContextualCallExpression(
4949
const left = ts.isCallExpression(node) ? node.expression : node.tag;
5050
if (
5151
ts.isPropertyAccessExpression(left) &&
52+
ts.isIdentifier(left.name) &&
5253
!luaKeywords.has(left.name.text) &&
5354
isValidLuaIdentifier(left.name.text)
5455
) {

src/transformation/visitors/literal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export function transformPropertyName(context: TransformationContext, node: ts.P
2121
return context.transformExpression(node.expression);
2222
} else if (ts.isIdentifier(node)) {
2323
return lua.createStringLiteral(node.text);
24+
} else if (ts.isPrivateIdentifier(node)) {
25+
throw new Error("PrivateIdentifier is not supported");
2426
} else {
2527
return context.transformExpression(node);
2628
}

src/transformation/visitors/modules/export.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ export const transformExportDeclaration: FunctionVisitor<ts.ExportDeclaration> =
136136
return undefined;
137137
}
138138

139+
if (ts.isNamespaceExport(node.exportClause)) {
140+
// export * as ns from "...";
141+
throw new Error("NamespaceExport is not supported");
142+
}
143+
139144
const exportSpecifiers = getExported(context, node.exportClause);
140145

141146
// export { ... };

test/legacy-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function transpileStringsAsProject(
2323
input: Record<string, string>,
2424
options: tstl.CompilerOptions = {}
2525
): tstl.TranspileResult {
26-
const optionsWithDefaults = {
26+
const optionsWithDefaults: tstl.CompilerOptions = {
2727
luaTarget: tstl.LuaTarget.Lua53,
2828
noHeader: true,
2929
skipLibCheck: true,

test/unit/annotations/forRange.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ test("invalid non-ambient @forRange function", () => {
3333
);
3434
});
3535

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

4141
expect(() => util.transpileString(code)).toThrow(
4242
InvalidForRangeCall(ts.createEmptyStatement(), "@forRange function must take 2 or 3 arguments.").message

test/unit/builtins/string.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test.each([
6363
["hello", "test", "bye"],
6464
["hello", 42],
6565
[42, "hello"],
66-
])("string.concat[+] (%p)", (...elements) => {
66+
])("string.concat[+] (%p)", (...elements: any[]) => {
6767
util.testExpression(elements.map(e => util.formatCode(e)).join(" + ")).expectToMatchJsResult();
6868
});
6969

0 commit comments

Comments
 (0)