X Tutup
Skip to content

correctly passing context to functions accessed as elements#313

Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
tomblind:element_call_fix
Dec 27, 2018
Merged

correctly passing context to functions accessed as elements#313
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
tomblind:element_call_fix

Conversation

@tomblind
Copy link
Collaborator

fixes #266

Also has a bit of refactoring in transpileCallExpression()


public transpileElementCall(node: ts.CallExpression): string {
if (!ts.isElementAccessExpression(node.expression)) {
throw TSTLErrors.InvalidPropertyCall(node);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be InvalidElementCall?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But, that would make sense! 😂

if (!signatureDeclaration
|| tsHelper.getDeclarationContextType(signatureDeclaration, this.checker) !== ContextType.Void) {
// Pass left-side as context
if (node.arguments.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This looks a little weird but I do understand it prevents some duplication. Maybe if you just improve the comment a little bit on the logic for this if statement, that would already help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alrighty

@Perryvw Perryvw merged commit b4366cd into TypeScriptToLua:master Dec 27, 2018
@tomblind tomblind deleted the element_call_fix branch December 27, 2018 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Losing context when calling method with a computed key

2 participants

X Tutup