Skip to content

Conversation

@Perryvw
Copy link
Member

@Perryvw Perryvw commented Aug 15, 2021

As a side effect of removing isInTupleReturn, this also fixes #1058

/** @tupleReturn */
function tuple(): [number, number, number] { return [3, 5, 1]; }
return tuple()[2];
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
Copy link
Member

Choose a reason for hiding this comment

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

Add a test for just:

        /** @tupleReturn */
         function tuple(): [number, number, number] { return [3, 5, 1]; };

(without the call). This should also result in a diagnostic

if (signature) {
if (getSignatureAnnotations(context, signature).has(AnnotationKind.TupleReturn)) {
context.diagnostics.push(annotationDeprecated(node, AnnotationKind.TupleReturn));
context.diagnostics.push(annotationRemoved(node, AnnotationKind.TupleReturn));
Copy link
Member

Choose a reason for hiding this comment

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

I think diagnostic.push should be removed from isTupleReturnCall(). isTupleReturnCall should just return true or false without side effects.
The diagnostic should only be pushed at the call location of isTupleReturnCall().
e.g.

if (isTupleReturnCall()) {
    context.diagnostic.push...
}

Which seems to already be the case???? https://github.com/TypeScriptToLua/TypeScriptToLua/pull/1090/files#diff-877ef39cd04cebdd5a0baf7a2090e119498765d5afc71abe08f32422d1dd1984R252
I wonder why the test does not fail because with this implementation, the diagnostic should get pushed multiple times?

@Perryvw Perryvw linked an issue Aug 16, 2021 that may be closed by this pull request
@lolleko lolleko self-requested a review August 16, 2021 15:11
@Perryvw Perryvw merged commit a013476 into master Aug 20, 2021
@Perryvw Perryvw deleted the remove-tuplereturn branch August 20, 2021 17:38
sanikoyes pushed a commit to sanikoyes/TypeScriptToLua that referenced this pull request Sep 24, 2021
* Remove tupleReturn annotation

* Change places tuplereturn diagnostics are added
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.

@link JSDoc annotation cause to fatal error

2 participants