mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 17:30:04 -05:00
fix: omit inlay hints for setters (#45228)
This commit is contained in:
@@ -67,13 +67,17 @@ namespace ts.InlayHints {
|
||||
if (preferences.includeInlayFunctionParameterTypeHints && isFunctionExpressionLike(node)) {
|
||||
visitFunctionExpressionLikeForParameterType(node);
|
||||
}
|
||||
if (preferences.includeInlayFunctionLikeReturnTypeHints && isFunctionLikeDeclaration(node)) {
|
||||
if (preferences.includeInlayFunctionLikeReturnTypeHints && isSignatureSupportingReturnAnnotation(node)) {
|
||||
visitFunctionDeclarationLikeForReturnType(node);
|
||||
}
|
||||
}
|
||||
return forEachChild(node, visitor);
|
||||
}
|
||||
|
||||
function isSignatureSupportingReturnAnnotation(node: Node): node is FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration {
|
||||
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
||||
}
|
||||
|
||||
function isFunctionExpressionLike(node: Node): node is ArrowFunction | FunctionExpression {
|
||||
return isArrowFunction(node) || isFunctionExpression(node);
|
||||
}
|
||||
@@ -206,7 +210,7 @@ namespace ts.InlayHints {
|
||||
return isLiteralExpression(node) || isBooleanLiteral(node) || isFunctionExpressionLike(node) || isObjectLiteralExpression(node) || isArrayLiteralExpression(node);
|
||||
}
|
||||
|
||||
function visitFunctionDeclarationLikeForReturnType(decl: FunctionLikeDeclaration) {
|
||||
function visitFunctionDeclarationLikeForReturnType(decl: FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration) {
|
||||
if (isArrowFunction(decl)) {
|
||||
if (!findChildOfKind(decl, SyntaxKind.OpenParenToken, file)) {
|
||||
return;
|
||||
@@ -236,7 +240,7 @@ namespace ts.InlayHints {
|
||||
addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl));
|
||||
}
|
||||
|
||||
function getTypeAnnotationPosition(decl: FunctionLikeDeclaration) {
|
||||
function getTypeAnnotationPosition(decl: FunctionDeclaration | ArrowFunction | FunctionExpression | MethodDeclaration | GetAccessorDeclaration) {
|
||||
const closeParenToken = findChildOfKind(decl, SyntaxKind.CloseParenToken, file);
|
||||
if (closeParenToken) {
|
||||
return closeParenToken.end;
|
||||
|
||||
Reference in New Issue
Block a user