Skip to content
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

Allow curly around @type jsdoc to be optional #20074

Merged
merged 4 commits into from
Nov 21, 2017

Conversation

weswigham
Copy link
Member

Fixes #19987

@weswigham weswigham requested review from sandersn, mhegazy and a user November 16, 2017 21:17
@weswigham
Copy link
Member Author

For reference, this reverses the decision made in #16947 for this to be an error, given that we have a large sample which uses @type tags without curly braces that validates under closure compiler, I'd say allowing the braces to be omitted is more correct.

@@ -6131,6 +6131,14 @@ namespace ts {
return jsDocTypeExpression ? { jsDocTypeExpression, diagnostics } : undefined;
}

function parseUnbracketedJSDocTypeExpression(): JSDocTypeExpression {
Copy link

Choose a reason for hiding this comment

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

This could be done in parseJSDocTypeExpression like we do with requireBraces, which happens to be no longer used!

@ghost
Copy link

ghost commented Nov 16, 2017

Sorry for the ambiguous issue title -- the problem fixed in #16947 was that we would parse number as a comment and not a type.

@weswigham weswigham force-pushed the curly-around-jsdoc-optional branch from 9ac05e2 to fbc05e8 Compare November 17, 2017 22:28
@weswigham weswigham force-pushed the curly-around-jsdoc-optional branch from fbc05e8 to 7bd89cf Compare November 17, 2017 22:29
@weswigham
Copy link
Member Author

@andy-ms I've merged the implementations and removed the unused overload.

@sandersn Did you want to look over this before its merged? I believe you had comments about the jsdoc scanner changes.

}
result.type = doInsideOfContext(NodeFlags.JSDoc, parseType);
parseExpected(SyntaxKind.CloseBraceToken);
if (!braceless) {
Copy link

@ghost ghost Nov 17, 2017

Choose a reason for hiding this comment

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

I have a recommended change at ff94f2d
This undoes the change to tryParseTypeExpression and directly calls parseJSDocTypeExpression with a mayOmitBraces parameter instead. If we'll parse a type whether there are braces or not we're no longer really "trying" to parse the type, we definitely will.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Looks good, your discussion in-person of the scanner changes was the missing piece before.

@weswigham weswigham merged commit a551c4c into microsoft:master Nov 21, 2017
@weswigham weswigham deleted the curly-around-jsdoc-optional branch November 21, 2017 00:10
errendir added a commit to errendir/TypeScript that referenced this pull request Nov 27, 2017
* origin/master: (28 commits)
  LEGO: check in for master to temporary branch.
  LEGO: check in for master to temporary branch.
  Removes redundant comments (microsoft#20214)
  Catch illegal jsdoc tags on constructors (microsoft#20045)
  Use stricter types for event bodies
  Use {} instead of any to improve type checking
  Update public API baseline
  Update project on PackageInstalledResponse
  Unswap arguments
  LEGO: check in for master to temporary branch.
  Fix visibility checking of mutually recursive exports (microsoft#19929)
  Add dt baseline folder to gitignore (microsoft#20205)
  Support getJSDocCommentsAndTags for special property assignments (microsoft#20193)
  Clean up outliningElementsCollector (microsoft#20143)
  Correct project root path passed to Typings Installer
  Check hasOwnProperty before copying property
  Convert legacy safe list keys to lowercase on construction
  Port generated lib files (microsoft#20177)
  Clean up lexical classifier (microsoft#20123)
  Allow curly around `@type` jsdoc to be optional (microsoft#20074)
  ...
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
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