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

Stop tag after @callback from crashing #48860

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8579,7 +8579,8 @@ namespace ts {
if (!comment) {
comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
}
return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start);
const end = comment !== undefined ? getNodePos() : typeExpression.end;
return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
}

function escapedTextsEqual(a: EntityName, b: EntityName): boolean {
Expand Down
19 changes: 19 additions & 0 deletions tests/cases/fourslash/jsTagAfterCallback1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
// @Filename: foo.js
// @allowJs: true
// @checkJs: true
//// /** @callback Listener @yeturn {ListenerBlock} */
//// /**
//// * The function used
//// * /*1*/ settings
//// */
//// class /*2*/ListenerBlock {
//// }

// Force a syntax tree to be created.
verify.noMatchingBracePositionInCurrentFile(0);

goTo.marker('1');
edit.insert('fenster');

verify.quickInfoAt('2', 'class ListenerBlock', 'The function used\nfenster settings')
19 changes: 19 additions & 0 deletions tests/cases/fourslash/jsTagAfterCallback2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
// @Filename: foo.js
// @allowJs: true
// @checkJs: true
//// /** @callback Listener @param x @yeturn {ListenerBlock} */
//// /**
//// * The function used
//// * /*1*/ settings
//// */
//// class /*2*/ListenerBlock {
//// }

// Force a syntax tree to be created.
verify.noMatchingBracePositionInCurrentFile(0);

goTo.marker('1');
edit.insert('fenster');

verify.quickInfoAt('2', 'class ListenerBlock', 'The function used\nfenster settings')
19 changes: 19 additions & 0 deletions tests/cases/fourslash/jsTagAfterTypedef1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
// @Filename: foo.js
// @allowJs: true
// @checkJs: true
//// /** @typedef Lister @property p @yeturn {ListenerBlock} */
//// /**
//// * The function used
//// * /*1*/ settings
//// */
//// class /*2*/ListenerBlock {
//// }

// Force a syntax tree to be created.
verify.noMatchingBracePositionInCurrentFile(0);

goTo.marker('1');
edit.insert('fenster');

verify.quickInfoAt('2', 'class ListenerBlock', 'The function used\nfenster settings')