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
9 changes: 8 additions & 1 deletion src/transformation/visitors/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
captureThisValue,
} from "./optional-chaining";
import { SyntaxKind } from "typescript";
import { getCustomNameFromSymbol } from "./identifier";

function addOneToArrayAccessArgument(
context: TransformationContext,
Expand Down Expand Up @@ -108,10 +109,16 @@ export function transformPropertyAccessExpressionWithCapture(
node: ts.PropertyAccessExpression,
thisValueCapture: lua.Identifier | undefined
): ExpressionWithThisValue {
const property = node.name.text;
const type = context.checker.getTypeAtLocation(node.expression);
const isOptionalLeft = isOptionalContinuation(node.expression);

let property = node.name.text;
const symbol = context.checker.getSymbolAtLocation(node.name);
const customName = getCustomNameFromSymbol(symbol);
if (customName) {
property = customName;
}

const constEnumValue = tryGetConstEnumValue(context, node);
if (constEnumValue) {
return { expression: constEnumValue };
Expand Down
2 changes: 2 additions & 0 deletions test/translation/__snapshots__/transformation.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ escapedCharsInTemplateString = "\\\\ \\0 \\b \\t \\n \\v \\f \\" ' \`"
nonEmptyTemplateString = ("Level 0: \\n\\t " .. ("Level 1: \\n\\t\\t " .. ("Level 3: \\n\\t\\t\\t " .. "Last level \\n --") .. " \\n --") .. " \\n --") .. " \\n --""
`;

exports[`Transformation (customNameWithNoSelf) 1`] = `"TestNamespace.pass()"`;

exports[`Transformation (exportStatement) 1`] = `
"local ____exports = {}
local xyz = 4
Expand Down
7 changes: 7 additions & 0 deletions test/translation/transformation/customNameWithNoSelf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @noSelf */
declare namespace TestNamespace {
/** @customName pass */
function fail(): void;
}

TestNamespace.fail();