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: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const isCI = require("is-ci");
const isCI = process.env.GITHUB_ACTIONS !== undefined;

/** @type {Partial<import("@jest/types").Config.DefaultOptions>} */
module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions language-extensions/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,11 @@ declare interface ReadonlyLuaSet<T extends AnyNotNil = AnyNotNil> extends LuaPai

interface ObjectConstructor {
/** Returns an array of keys of an object, when iterated with `pairs`. */
keys<K>(o: LuaPairsIterable<K, any> | LuaPairsKeyIterable<K>): K[];
keys<K extends AnyNotNil>(o: LuaPairsIterable<K, any> | LuaPairsKeyIterable<K>): K[];

/** Returns an array of values of an object, when iterated with `pairs`. */
values<V>(o: LuaPairsIterable<any, V>): V[];

/** Returns an array of key/values of an object, when iterated with `pairs`. */
entries<K, V>(o: LuaPairsIterable<K, V>): Array<[K, V]>;
entries<K extends AnyNotNil, V>(o: LuaPairsIterable<K, V>): Array<[K, V]>;
}
12,053 changes: 7,071 additions & 4,982 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
"lint:prettier": "prettier --check . || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
"lint:eslint": "eslint . --ext .js,.ts",
"fix:prettier": "prettier --write .",
"check:language-extensions": "tsc language-extensions/index.d.ts",
"check:language-extensions": "tsc --strict language-extensions/index.d.ts",
"preversion": "npm run build && npm test",
"postversion": "git push && git push --tags"
},
"bin": {
"tstl": "dist/tstl.js"
},
"engines": {
"node": ">=12.13.0"
"node": ">=16.10.0"
},
"peerDependencies": {
"typescript": "~4.7.3"
"typescript": "~4.8.2"
},
"dependencies": {
"enhanced-resolve": "^5.8.2",
Expand All @@ -56,20 +56,20 @@
"@types/jest": "^27.5.2",
"@types/node": "^13.7.7",
"@types/resolve": "1.14.0",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.17.0",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1",
"eslint": "^8.23.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.4.6",
"eslint-plugin-jest": "^26.8.7",
"fs-extra": "^8.1.0",
"javascript-stringify": "^2.0.1",
"jest": "^27.3.0",
"jest-circus": "^27.3.0",
"lua-types": "^2.11.0",
"jest": "^28.1.3",
"jest-circus": "^29.0.1",
"lua-types": "^2.12.1",
"lua-wasm-bindings": "^0.2.2",
"prettier": "^2.3.2",
"ts-jest": "^27.1.3",
"ts-node": "^10.3.0",
"typescript": "~4.7.3"
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"typescript": "~4.8.2"
}
}
4 changes: 2 additions & 2 deletions src/transformation/utils/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function isExpressionWithEvaluationEffect(node: ts.Expression): boolean {

export function getFunctionTypeForCall(context: TransformationContext, node: ts.CallExpression) {
const signature = context.checker.getResolvedSignature(node);
if (!signature || !signature.declaration) {
if (!signature?.declaration) {
return;
}
const typeDeclaration = findFirstNodeAbove(signature.declaration, ts.isTypeAliasDeclaration);
Expand All @@ -110,7 +110,7 @@ export function isConstIdentifier(context: TransformationContext, node: ts.Node)
return false;
}
const symbol = context.checker.getSymbolAtLocation(identifier);
if (!symbol || !symbol.declarations) {
if (!symbol?.declarations) {
return false;
}
return symbol.declarations.some(
Expand Down
4 changes: 2 additions & 2 deletions src/transformation/visitors/class/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ function transformClassLikeDeclaration(
result.push(...decorationStatements);

// Decorate the class
if (classDeclaration.decorators) {
if (ts.canHaveDecorators(classDeclaration) && ts.getDecorators(classDeclaration)) {
const decoratingExpression = createDecoratingExpression(
context,
classDeclaration.kind,
classDeclaration.decorators.map(d => transformDecoratorExpression(context, d)),
ts.getDecorators(classDeclaration)?.map(d => transformDecoratorExpression(context, d)) ?? [],
localClassName
);
const decoratingStatement = lua.createAssignmentStatement(localClassName, decoratingExpression);
Expand Down
6 changes: 4 additions & 2 deletions src/transformation/visitors/class/members/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ export function createPropertyDecoratingExpression(
node: ts.PropertyDeclaration | ts.AccessorDeclaration,
className: lua.Identifier
): lua.Expression | undefined {
if (!node.decorators) return;
if (!ts.canHaveDecorators(node)) return;
const decorators = ts.getDecorators(node);
if (!decorators) return;
const propertyName = transformPropertyName(context, node.name);
const propertyOwnerTable = transformMemberExpressionOwnerName(node, className);
return createDecoratingExpression(
context,
node.kind,
node.decorators.map(d => transformDecoratorExpression(context, d)),
decorators.map(d => transformDecoratorExpression(context, d)),
propertyOwnerTable,
propertyName
);
Expand Down
20 changes: 11 additions & 9 deletions src/transformation/visitors/class/members/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ export function createMethodDecoratingExpression(

const parameterDecorators = node.parameters
.flatMap((parameter, index) =>
parameter.decorators?.map(decorator =>
transformLuaLibFunction(
context,
LuaLibFeature.DecorateParam,
node,
lua.createNumericLiteral(index),
transformDecoratorExpression(context, decorator)
ts
.getDecorators(parameter)
?.map(decorator =>
transformLuaLibFunction(
context,
LuaLibFeature.DecorateParam,
node,
lua.createNumericLiteral(index),
transformDecoratorExpression(context, decorator)
)
)
)
)
.filter(isNonNull);

const methodDecorators = node.decorators?.map(d => transformDecoratorExpression(context, d)) ?? [];
const methodDecorators = ts.getDecorators(node)?.map(d => transformDecoratorExpression(context, d)) ?? [];

if (methodDecorators.length > 0 || parameterDecorators.length > 0) {
const decorateMethod = createDecoratingExpression(
Expand Down
7 changes: 1 addition & 6 deletions src/transformation/visitors/modules/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,7 @@ function transformExportSpecifiersFrom(
)
);

const importDeclaration = ts.factory.createImportDeclaration(
statement.decorators,
statement.modifiers,
importClause,
moduleSpecifier
);
const importDeclaration = ts.factory.createImportDeclaration(statement.modifiers, importClause, moduleSpecifier);

// Wrap in block to prevent imports from hoisting out of `do` statement
const [block] = transformScopeBlock(context, ts.factory.createBlock([importDeclaration]), ScopeType.Block);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as path from "path";
export function castArray<T>(value: T | T[]): T[];
export function castArray<T>(value: T | readonly T[]): readonly T[];
export function castArray<T>(value: T | readonly T[]): readonly T[] {
return Array.isArray(value) ? value : [value];
return Array.isArray(value) ? value : [value as T];
}

export const intersperse = <T>(values: readonly T[], separator: T): T[] =>
Expand Down