mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 22:32:33 -05:00
fix(60375): Parameter inlay hint is incorrect when function has a this type (#60378)
This commit is contained in:
@@ -103,6 +103,7 @@ import {
|
||||
NodeArray,
|
||||
NodeBuilderFlags,
|
||||
ParameterDeclaration,
|
||||
parameterIsThisKeyword,
|
||||
PrefixUnaryExpression,
|
||||
PropertyDeclaration,
|
||||
QuotePreference,
|
||||
@@ -437,26 +438,28 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
||||
const param = node.parameters[i];
|
||||
if (!isHintableDeclaration(param)) {
|
||||
let pos = 0;
|
||||
for (const param of node.parameters) {
|
||||
if (isHintableDeclaration(param)) {
|
||||
addParameterTypeHint(param, parameterIsThisKeyword(param) ? signature.thisParameter : signature.parameters[pos]);
|
||||
}
|
||||
if (parameterIsThisKeyword(param)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const effectiveTypeAnnotation = getEffectiveTypeAnnotationNode(param);
|
||||
if (effectiveTypeAnnotation) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const typeHints = getParameterDeclarationTypeHints(signature.parameters[i]);
|
||||
if (!typeHints) {
|
||||
continue;
|
||||
}
|
||||
|
||||
addTypeHints(typeHints, param.questionToken ? param.questionToken.end : param.name.end);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
function addParameterTypeHint(node: ParameterDeclaration, symbol: Symbol | undefined) {
|
||||
const effectiveTypeAnnotation = getEffectiveTypeAnnotationNode(node);
|
||||
if (effectiveTypeAnnotation || symbol === undefined) return;
|
||||
|
||||
const typeHints = getParameterDeclarationTypeHints(symbol);
|
||||
if (typeHints === undefined) return;
|
||||
|
||||
addTypeHints(typeHints, node.questionToken ? node.questionToken.end : node.name.end);
|
||||
}
|
||||
|
||||
function getParameterDeclarationTypeHints(symbol: Symbol) {
|
||||
const valueDeclaration = symbol.valueDeclaration;
|
||||
if (!valueDeclaration || !isParameter(valueDeclaration)) {
|
||||
|
||||
Reference in New Issue
Block a user