Skip to content

Commit ea5a43a

Browse files
TypeScript Bota-tarasyuk
TypeScript Bot
andauthored
Cherry-pick PR #47830 into release-4.6 (#47928)
Component commits: 8f0e935 fix(47820): forbid extraction jsdoc Co-authored-by: Oleksandr T <[email protected]>
1 parent b6ec37a commit ea5a43a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/services/refactors/extractSymbol.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ namespace ts.refactor.extractSymbol {
283283

284284
// Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span.
285285
// This may fail (e.g. you select two statements in the root of a source file)
286-
const start = cursorRequest ? getExtractableParent(startToken): getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
286+
const start = cursorRequest ? getExtractableParent(startToken) : getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
287287

288288
// Do the same for the ending position
289289
const end = cursorRequest ? start : getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
@@ -299,7 +299,7 @@ namespace ts.refactor.extractSymbol {
299299
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
300300
}
301301

302-
if (isJSDoc(start)) {
302+
if (start.flags & NodeFlags.JSDoc) {
303303
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
304304
}
305305

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////**
4+
//// * /*a*//*b*/
5+
//// * {@link Foo}
6+
//// */
7+
8+
goTo.select("a", "b");
9+
verify.not.refactorAvailableForTriggerReason("invoked", "Extract Symbol");

0 commit comments

Comments
 (0)