fix(47562): Add option to suppress type hint if variable name matches type name (#48529)

* fix(47562): Add option to suppress type hint if variable name matches type

* Remove the unnecessary debug code

* Re-run gulp runtests

* Use equateStringsCaseInsensitive to compare strings
This commit is contained in:
Huy
2022-05-25 12:07:38 -07:00
committed by GitHub
parent b57d6e1df4
commit 1fb2b2d70f
7 changed files with 38 additions and 4 deletions

View File

@@ -137,6 +137,10 @@ namespace ts.InlayHints {
const typeDisplayString = printTypeInSingleLine(declarationType);
if (typeDisplayString) {
const isVariableNameMatchesType = preferences.includeInlayVariableTypeHintsWhenTypeMatchesName === false && equateStringsCaseInsensitive(decl.name.getText(), typeDisplayString);
if (isVariableNameMatchesType) {
return;
}
addTypeHints(typeDisplayString, decl.name.end);
}
}