Cherry-pick PR #47830 into release-4.6 (#47928)

Component commits:
8f0e9356c3 fix(47820): forbid extraction jsdoc

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
This commit is contained in:
TypeScript Bot 2022-02-17 16:59:09 -08:00 committed by GitHub
parent b6ec37aac2
commit ea5a43a290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -283,7 +283,7 @@ namespace ts.refactor.extractSymbol {
// Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span.
// This may fail (e.g. you select two statements in the root of a source file)
const start = cursorRequest ? getExtractableParent(startToken): getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
const start = cursorRequest ? getExtractableParent(startToken) : getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
// Do the same for the ending position
const end = cursorRequest ? start : getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
@ -299,7 +299,7 @@ namespace ts.refactor.extractSymbol {
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
}
if (isJSDoc(start)) {
if (start.flags & NodeFlags.JSDoc) {
return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
}

View File

@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
/////**
//// * /*a*//*b*/
//// * {@link Foo}
//// */
goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("invoked", "Extract Symbol");