Skip to content

Return diagnostics instead of throwing errors#769

Merged
Perryvw merged 49 commits intoTypeScriptToLua:masterfrom
ark120202:diagnostics
Mar 15, 2020
Merged

Return diagnostics instead of throwing errors#769
Perryvw merged 49 commits intoTypeScriptToLua:masterfrom
ark120202:diagnostics

Conversation

@ark120202
Copy link
Copy Markdown
Contributor

Resolves #412, closes #567.

@ark120202 ark120202 marked this pull request as ready for review December 12, 2019 22:05
@ark120202 ark120202 requested a review from Perryvw March 11, 2020 11:51
return transformIdentifier(context, name);
} else if (ts.isBindingElement(name) && ts.isIdentifier(name.name)) {
} else if (ts.isBindingElement(name)) {
// TODO: It should always be true when called from `transformVariableDeclaration`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

so what is the action TODO here? Handle the potential failure?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The assertion below is invalid in the case of for (const [[x]] of string.gmatch('', '')) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That does not really answer my question: What is the action we have to do here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, handle it somehow - assert is meant to never fail under the expected conditions. I haven't looked much into it, but in case of transformVariableDeclaration it's only used in the optimization transform, so maybe the same thing should be done in the other case

statement: ts.ForOfStatement,
block: lua.Block
): lua.Statement {
let valueVariable: lua.Identifier;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would have preferred this ForIn refactor to have been in its own PR...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just found the easiest way to resolve TODOs ¯\_(ツ)_/¯
It was already changed quite a lot for diagnostics anyway: master...9eaa4ad#diff-198b7c2ac4e943adf558f34c21ac4143

return transformIdentifier(context, name);
} else if (ts.isBindingElement(name) && ts.isIdentifier(name.name)) {
} else if (ts.isBindingElement(name)) {
// TODO: It should always be true when called from `transformVariableDeclaration`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That does not really answer my question: What is the action we have to do here?

@Perryvw Perryvw merged commit 9f61a82 into TypeScriptToLua:master Mar 15, 2020
@ark120202 ark120202 deleted the diagnostics branch March 15, 2020 13:04
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.

Compiler errors are output to lua file Return ts diagnostics instead of throwing errors from transformer

2 participants