X Tutup
Skip to content

New functions - tests#303

Merged
Perryvw merged 27 commits intoTypeScriptToLua:new-functionsfrom
tomblind:new-functions
Dec 12, 2018
Merged

New functions - tests#303
Perryvw merged 27 commits intoTypeScriptToLua:new-functionsfrom
tomblind:new-functions

Conversation

@tomblind
Copy link
Collaborator

This PR adds a full suite of tests for function assignments (both valid and invalid).

It also addresses edge cases found, specifically a case where lambda-class-properties marked with 'this: void' would still be considered method-like.

if (name) {
return new TranspileError(`Unsupported conversion from function to method "${name}".`, node);
return new TranspileError(`Unsupported conversion from function to method "${name}". `
+ `To fix, wrap the function in an arrow function.`,
Copy link
Member

Choose a reason for hiding this comment

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

Should be a very specific arrow function right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea is that function expressions can have their context type deduced based on what they are being assigned to, so a simple arrow function should suffice. There's a few edge cases where this doesn't work and 'this' has to be explicitly stated or you will still get this error, though.

@@ -6,6 +6,23 @@ const fs = require("fs");

export class AssignmentTests {
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean we can get rid of the assignments translation test file? Or is it already gone on this branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not in this branch, but it's removed in master, so when things get merged it should be gone.

@Perryvw Perryvw merged commit cc6d403 into TypeScriptToLua:new-functions Dec 12, 2018
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.

2 participants

X Tutup