Skip to content

annotateWithTypeFromJSDoc: Use changes.insertTypeAnnotation instead of replaceNode #22404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Mar 8, 2018

Conversation

ghost
Copy link

@ghost ghost commented Mar 8, 2018

Fixes #22358

@ghost ghost requested review from sandersn and amcasey March 8, 2018 18:24
@ghost ghost merged commit a49e83f into master Mar 8, 2018
@ghost ghost deleted the jsdoctype_insertTypeAnnotation branch March 8, 2018 19:47
@@ -9,6 +9,6 @@ verify.codeFix({
newFileContent:
`class C {
/** @return {number} */
get c(): number { return 12; }
get c(): number { return 12 }
Copy link
Member

Choose a reason for hiding this comment

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

Why did we drop the semicolon?

Copy link
Author

@ghost ghost Mar 8, 2018

Choose a reason for hiding this comment

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

There's no semicolon in the original (line 4 of this file). Previously we would reformat the body, but now we just add a type annotation.

return getJSDocType(node);
}
export function getEffectiveTypeAnnotationNode(node: Node): TypeNode | undefined {
return (node as HasType).type || (isInJavaScriptFile(node) ? getJSDocType(node) : undefined);
Copy link
Member

Choose a reason for hiding this comment

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

For my own understanding, if node is not a HasType but does have a type property with a defined value, we will return that (as we did before?)?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the assumption is that only a HasType has a type.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants