Allow JSDoc casts of parenthesized expressions in JS#17211
Closed
weswigham wants to merge 10 commits intoparse-jsdoc-with-ts-type-parserfrom
Closed
Allow JSDoc casts of parenthesized expressions in JS#17211weswigham wants to merge 10 commits intoparse-jsdoc-with-ts-type-parserfrom
weswigham wants to merge 10 commits intoparse-jsdoc-with-ts-type-parserfrom
Conversation
sandersn
approved these changes
Jul 17, 2017
Member
sandersn
left a comment
There was a problem hiding this comment.
Looks good, although I have one question and two nits before you merge.
|
|
||
| function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type { | ||
| if (isInJavaScriptFile(node)) { | ||
| if (node.jsDoc) { |
Member
There was a problem hiding this comment.
why not combine these predicates?
| function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type { | ||
| if (isInJavaScriptFile(node)) { | ||
| if (node.jsDoc) { | ||
| const typecasts = flatten<JSDocTag>(map(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag))); |
Member
There was a problem hiding this comment.
can you use flatMap instead? filter should always return an array so you don't need the if (isArray ... check in flatten.
|
|
||
| class SomeBase { | ||
| constructor() { | ||
| this.p = 42; |
Member
There was a problem hiding this comment.
These tests cases don't have type annotations. But based on your follow-up comment in the associated bug, the syntax
/** @type {number} */
this.p = 42;should also work. I just want to confirm that this is not addressed in this PR.
Parse jsdoc with normal TS type parser
* Minor cleanups in builder * Use enumerateInsertsAndDeletes
…the LHS of a VariableDeclaration (#17205)
… ones (#17179) * Reuse stored types for any[] and Promise<any> instead of creating new ones * Don't store anyPromiseType
`readFile` may return undefined
* Issue template: Recommand to run `tsc` directly * List some common build tools
9a29ac4 to
b5ec445
Compare
Member
Author
|
I'll reopen this against master (with feedback integrated) shortly. |
weswigham
added a commit
that referenced
this pull request
Jul 17, 2017
Merged
weswigham
added a commit
that referenced
this pull request
Jul 18, 2017
* Allow jsdoc casts of parenthesized expressions * Feedback from #17211
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5158
Based on #17176, since that changes some of the machinery that could have affected this.