-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow curly around @type
jsdoc to be optional
#20074
Conversation
For reference, this reverses the decision made in #16947 for this to be an error, given that we have a large sample which uses |
src/compiler/parser.ts
Outdated
@@ -6131,6 +6131,14 @@ namespace ts { | |||
return jsDocTypeExpression ? { jsDocTypeExpression, diagnostics } : undefined; | |||
} | |||
|
|||
function parseUnbracketedJSDocTypeExpression(): JSDocTypeExpression { |
There was a problem hiding this comment.
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!
Sorry for the ambiguous issue title -- the problem fixed in #16947 was that we would parse |
9ac05e2
to
fbc05e8
Compare
fbc05e8
to
7bd89cf
Compare
@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. |
src/compiler/parser.ts
Outdated
} | ||
result.type = doInsideOfContext(NodeFlags.JSDoc, parseType); | ||
parseExpected(SyntaxKind.CloseBraceToken); | ||
if (!braceless) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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.
* 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) ...
Fixes #19987