Support for single-character escape sequences#160
Merged
Perryvw merged 5 commits intoTypeScriptToLua:masterfrom Jul 28, 2018
Merged
Support for single-character escape sequences#160Perryvw merged 5 commits intoTypeScriptToLua:masterfrom
Perryvw merged 5 commits intoTypeScriptToLua:masterfrom
Conversation
Perryvw
requested changes
Jul 28, 2018
Member
Perryvw
left a comment
There was a problem hiding this comment.
You forgot transpileTemplateExpression, could you refactor the method as suggested and use it on the literal strings in transpileTemplateExpression too?
src/Transpiler.ts
Outdated
| } | ||
| } | ||
|
|
||
| public transpileStringLiteralExpression(node: ts.Node): string { |
Member
There was a problem hiding this comment.
I would suggest refactoring to escapeString(str: string): string and just calling this wherever suitable.
| return this.transpileIdentifier(node as ts.Identifier); | ||
| case ts.SyntaxKind.StringLiteral: | ||
| case ts.SyntaxKind.NoSubstitutionTemplateLiteral: | ||
| const text = (node as ts.StringLiteral).text; |
Member
There was a problem hiding this comment.
Then this would just be something like const text = this.escapeString((node as ts.StringLiteral).text);
Rename to escapeString
Contributor
Author
|
I realized the missing support for template strings as well, wasn't quick enough to ninja-commit it though. Support & tests added for template strings and requested changes applied. |
Perryvw
approved these changes
Jul 28, 2018
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.
With this update single-character escape sequences will be preserved, e.g.
Is transpiled to
Previously you had to double escape them, for example
"\n"would have resulted in an actual linebreak in the transpiled lua code.