New functions - tests#303
Merged
Perryvw merged 27 commits intoTypeScriptToLua:new-functionsfrom Dec 12, 2018
Merged
Conversation
…gning to untyped vars
Perryvw
approved these changes
Dec 11, 2018
| 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.`, |
Member
There was a problem hiding this comment.
Should be a very specific arrow function right?
Collaborator
Author
There was a problem hiding this comment.
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 { | |||
Member
There was a problem hiding this comment.
Does this mean we can get rid of the assignments translation test file? Or is it already gone on this branch?
Collaborator
Author
There was a problem hiding this comment.
Not in this branch, but it's removed in master, so when things get merged it should be gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.