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
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ module.exports = {

"jest/expect-expect": "off",
"jest/consistent-test-it": ["error", { fn: "test", withinDescribe: "test" }],
"jest/no-disabled-tests": "error",
"jest/no-expect-resolves": "error",
"jest/no-identical-title": "off",
"jest/no-test-return-statement": "error",
"jest/no-truthy-falsy": "error",
"jest/prefer-spy-on": "error",
Expand Down
968 changes: 258 additions & 710 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,26 @@
"engines": {
"node": ">=12.13.0"
},
"peerDependencies": {
"typescript": "~4.4.3"
},
"dependencies": {
"enhanced-resolve": "^5.8.2",
"resolve": "^1.15.1",
"source-map": "^0.7.3",
"typescript": "~4.3.5"
"typescript": "~4.4.3"
},
"devDependencies": {
"@types/fs-extra": "^8.1.0",
"@types/glob": "^7.1.1",
"@types/jest": "^25.1.3",
"@types/node": "^13.7.7",
"@types/resolve": "1.14.0",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"eslint": "^7.28.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jest": "^23.8.2",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.4.0",
"fs-extra": "^8.1.0",
"javascript-stringify": "^2.0.1",
"jest": "^26.0.1",
Expand All @@ -66,6 +69,6 @@
"lua-wasm-bindings": "^0.2.2",
"prettier": "^2.3.2",
"ts-jest": "^26.3.0",
"ts-node": "^8.6.2"
"ts-node": "^10.2.1"
}
}
2 changes: 1 addition & 1 deletion src/lualib/Symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const ____symbolMetatable = {
};

function __TS__Symbol(this: void, description?: string | number): symbol {
return setmetatable({ description }, ____symbolMetatable) as symbol;
return setmetatable({ description }, ____symbolMetatable) as unknown as symbol;
}

Symbol = {
Expand Down
6 changes: 4 additions & 2 deletions src/transpilation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export function resolvePlugin(
return { error: cliDiagnostics.compilerOptionRequiresAValueOfType(optionName, "string") };
}

const isModuleNotFoundError = (error: any) => error.code === "MODULE_NOT_FOUND";

let resolved: string;
try {
resolved = resolve.sync(query, { basedir, extensions: [".js", ".ts", ".tsx"] });
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
if (!isModuleNotFoundError(err)) throw err;
return { error: diagnosticFactories.couldNotResolveFrom(kind, query, basedir) };
}

Expand All @@ -61,7 +63,7 @@ export function resolvePlugin(
const tsNode: typeof import("ts-node") = require(tsNodePath);
tsNode.register({ transpileOnly: true });
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
if (!isModuleNotFoundError(err)) throw err;
return { error: diagnosticFactories.toLoadItShouldBeTranspiled(kind, query) };
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/unit/builtins/numbers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ test.each([
util.testExpression(code).expectToMatchJsResult();
});

// Current implementation does not allow this
// eslint-disable-next-line jest/no-disabled-tests
test.skip.each(["NaN", "Infinity"])("%s reassignment", name => {
util.testFunction`
const ${name} = 1;
Expand Down
2 changes: 2 additions & 0 deletions test/unit/error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ test("throwString", () => {
`.expectToEqual(new util.ExecutionError("Some Error"));
});

// TODO: Finally does not behave like it should, see #1137
// eslint-disable-next-line jest/no-disabled-tests
test.skip.each([0, 1, 2])("re-throw (%p)", i => {
util.testFunction`
const i: number = ${i};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1538,9 +1538,10 @@ main.ts(4,24): error TSTL: Unable to convert function with no 'this' parameter t

exports[`Invalid function tuple assignment: diagnostics 1`] = `
"main.ts(5,13): error TS2322: Type '[number, Meth]' is not assignable to type '[number, Func]'.
Type 'Meth' is not assignable to type 'Func'.
The 'this' types of each signature are incompatible.
Type 'void' is not assignable to type '{}'.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'Meth' is not assignable to type 'Func'.
The 'this' types of each signature are incompatible.
Type 'void' is not assignable to type '{}'.
main.ts(5,38): error TSTL: Unable to convert function with a 'this' parameter to function with no 'this'. To fix, wrap in an arrow function, or declare with 'this: void'."
`;

Expand Down
8 changes: 6 additions & 2 deletions test/unit/loops.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,12 @@ describe("for...of empty destructuring", () => {
});
};

describe("declaration", () => declareTests("const "));
describe("assignment", () => declareTests(""));
describe("declaration", () => {
declareTests("const ");
});
describe("assignment", () => {
declareTests("");
});
});

for (const testCase of [
Expand Down
2 changes: 2 additions & 0 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ end)());`;
try {
result = vm.runInContext(this.getJsCodeWithWrapper(), globalContext);
} catch (error) {
const hasMessage = (error: any): error is { message: string } => error.message !== undefined;
assert(hasMessage(error));
return new ExecutionError(error.message);
}

Expand Down