-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fix node.getStart()
for nodes spanning multiline JSDoc comments
#43854
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -478,7 +478,12 @@ namespace ts { | |
return getTokenPosOfNode((<SyntaxList>node)._children[0], sourceFile, includeJsDoc); | ||
} | ||
|
||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like an OK fix, but I don't think skipTrivia is called on the inside of jsdoc anywhere else. Maybe there should be a completely separate code path? I haven't thought about it deeply, so it's likely that skipTrivia is 98% right and just needed this tweak to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it’s definitely true that I didn’t pass the parameter anywhere else. It occurred to me that I could accomplish the same thing by wrapping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ummm, me too. Neither one of these functions are specific to jsdoc, so jsdoc-specific code is surprise in both. Probably means that this is good enough. |
||
return skipTrivia( | ||
(sourceFile || getSourceFileOfNode(node)).text, | ||
node.pos, | ||
/*stopAfterLineBreak*/ false, | ||
/*stopAtComments*/ false, | ||
isInJSDoc(node)); | ||
} | ||
|
||
export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @allowJs: true | ||
// @checkJs: true | ||
|
||
// @Filename: index.js | ||
//// /** | ||
//// * @typedef {{ | ||
//// * [|foo|]: string; | ||
//// * [|bar|]: number; | ||
//// * }} Foo | ||
//// */ | ||
//// | ||
//// /** @type {Foo} */ | ||
//// const x = { | ||
//// [|foo|]: "", | ||
//// [|bar|]: 42, | ||
//// }; | ||
|
||
verify.rangesWithSameTextAreDocumentHighlights(); |
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.
Dont you need to set canConsumeStar to false in the default case as well?
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 don’t think so—the default case is either whitespace (which doesn’t change whether we can consume a leading
*
) or it breaks and returns.