mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fix(55937): 'Infer function return type' offered in preceding trivia (#55938)
This commit is contained in:
parent
d9cd2d0bd0
commit
c640c5de0a
@ -10,7 +10,7 @@ import {
|
||||
FunctionDeclaration,
|
||||
FunctionExpression,
|
||||
getLocaleSpecificMessage,
|
||||
getTokenAtPosition,
|
||||
getTouchingPropertyName,
|
||||
isArrowFunction,
|
||||
isBlock,
|
||||
isInJSFile,
|
||||
@ -104,7 +104,7 @@ function doChange(sourceFile: SourceFile, changes: textChanges.ChangeTracker, de
|
||||
function getInfo(context: RefactorContext): FunctionInfo | RefactorErrorInfo | undefined {
|
||||
if (isInJSFile(context.file) || !refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return;
|
||||
|
||||
const token = getTokenAtPosition(context.file, context.startPosition);
|
||||
const token = getTouchingPropertyName(context.file, context.startPosition);
|
||||
const declaration = findAncestor(token, n =>
|
||||
isBlock(n) || n.parent && isArrowFunction(n.parent) && (n.kind === SyntaxKind.EqualsGreaterThanToken || n.parent.body === n) ? "quit" :
|
||||
isConvertibleDeclaration(n)) as ConvertibleDeclaration | undefined;
|
||||
|
||||
10
tests/cases/fourslash/refactorInferFunctionReturnType24.ts
Normal file
10
tests/cases/fourslash/refactorInferFunctionReturnType24.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////let x = 10;/*a*//*b*/
|
||||
////
|
||||
////function func() {
|
||||
//// return 10;
|
||||
////}
|
||||
|
||||
goTo.select("a", "b");
|
||||
verify.not.refactorAvailable("Infer function return type");
|
||||
Loading…
x
Reference in New Issue
Block a user