Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TS's includeInlayVariableTypeHintsWhenTypeMatchesName setting #150489

Merged
merged 2 commits into from May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions extensions/typescript-language-features/package.json
Expand Up @@ -301,6 +301,12 @@
"markdownDescription": "%configuration.inlayHints.variableTypes.enabled%",
"scope": "resource"
},
"typescript.inlayHints.variableTypes.suppressWhenTypeMatchesName": {
"type": "boolean",
"default": true,
"markdownDescription": "%configuration.inlayHints.variableTypes.suppressWhenTypeMatchesName%",
"scope": "resource"
},
"typescript.inlayHints.propertyDeclarationTypes.enabled": {
"type": "boolean",
"default": false,
Expand Down Expand Up @@ -353,6 +359,12 @@
"markdownDescription": "%configuration.inlayHints.variableTypes.enabled%",
"scope": "resource"
},
"javascript.inlayHints.variableTypes.suppressWhenTypeMatchesName": {
"type": "boolean",
"default": true,
"markdownDescription": "%configuration.inlayHints.variableTypes.suppressWhenTypeMatchesName%",
"scope": "resource"
},
"javascript.inlayHints.propertyDeclarationTypes.enabled": {
"type": "boolean",
"default": false,
Expand Down
6 changes: 2 additions & 4 deletions extensions/typescript-language-features/package.nls.json
Expand Up @@ -88,10 +88,7 @@
"message": "Enable/disable inlay hints for parameter names:\n```typescript\n\nparseInt(/* str: */ '123', /* radix: */ 8)\n \n```\nRequires using TypeScript 4.4+ in the workspace.",
"comment": "The text inside the ``` block is code and should not be localized."
},
"configuration.inlayHints.parameterNames.suppressWhenArgumentMatchesName": {
"message": "Suppress parameter name hints on arguments whose text is identical to the parameter name.",
"comment": "The text inside the ``` block is code and should not be localized."
},
"configuration.inlayHints.parameterNames.suppressWhenArgumentMatchesName": "Suppress parameter name hints on arguments whose text is identical to the parameter name.",
"configuration.inlayHints.parameterTypes.enabled": {
"message": "Enable/disable inlay hints for implicit parameter types:\n```typescript\n\nel.addEventListener('click', e /* :MouseEvent */ => ...)\n \n```\nRequires using TypeScript 4.4+ in the workspace.",
"comment": "The text inside the ``` block is code and should not be localized."
Expand All @@ -100,6 +97,7 @@
"message": "Enable/disable inlay hints for implicit variable types:\n```typescript\n\nconst foo /* :number */ = Date.now();\n \n```\nRequires using TypeScript 4.4+ in the workspace.",
"comment": "The text inside the ``` block is code and should not be localized."
},
"configuration.inlayHints.variableTypes.suppressWhenTypeMatchesName": "Suppress type hints on variables whose name is identical to the type name. Requires using TypeScript 4.8+ in the workspace.",
"configuration.inlayHints.propertyDeclarationTypes.enabled": {
"message": "Enable/disable inlay hints for implicit types on property declarations:\n```typescript\n\nclass Foo {\n\tprop /* :number */ = Date.now();\n}\n \n```\nRequires using TypeScript 4.4+ in the workspace.",
"comment": "The text inside the ``` block is code and should not be localized."
Expand Down
Expand Up @@ -210,6 +210,7 @@ export class InlayHintSettingNames {
static readonly parameterNamesSuppressWhenArgumentMatchesName = 'inlayHints.parameterNames.suppressWhenArgumentMatchesName';
static readonly parameterNamesEnabled = 'inlayHints.parameterTypes.enabled';
static readonly variableTypesEnabled = 'inlayHints.variableTypes.enabled';
static readonly variableTypesSuppressWhenTypeMatchesName = 'inlayHints.variableTypes.suppressWhenTypeMatchesName';
static readonly propertyDeclarationTypesEnabled = 'inlayHints.propertyDeclarationTypes.enabled';
static readonly functionLikeReturnTypesEnabled = 'inlayHints.functionLikeReturnTypes.enabled';
static readonly enumMemberValuesEnabled = 'inlayHints.enumMemberValues.enabled';
Expand All @@ -221,6 +222,7 @@ export function getInlayHintsPreferences(config: vscode.WorkspaceConfiguration)
includeInlayParameterNameHintsWhenArgumentMatchesName: !config.get<boolean>(InlayHintSettingNames.parameterNamesSuppressWhenArgumentMatchesName, true),
includeInlayFunctionParameterTypeHints: config.get<boolean>(InlayHintSettingNames.parameterNamesEnabled, false),
includeInlayVariableTypeHints: config.get<boolean>(InlayHintSettingNames.variableTypesEnabled, false),
includeInlayVariableTypeHintsWhenTypeMatchesName: !config.get<boolean>(InlayHintSettingNames.variableTypesSuppressWhenTypeMatchesName, true),
includeInlayPropertyDeclarationTypeHints: config.get<boolean>(InlayHintSettingNames.propertyDeclarationTypesEnabled, false),
includeInlayFunctionLikeReturnTypeHints: config.get<boolean>(InlayHintSettingNames.functionLikeReturnTypesEnabled, false),
includeInlayEnumMemberValueHints: config.get<boolean>(InlayHintSettingNames.enumMemberValuesEnabled, false),
Expand Down
Expand Up @@ -15,14 +15,15 @@ import { Position } from '../utils/typeConverters';
import FileConfigurationManager, { getInlayHintsPreferences, InlayHintSettingNames } from './fileConfigurationManager';


const inlayHintSettingNames = [
const inlayHintSettingNames = Object.freeze([
InlayHintSettingNames.parameterNamesSuppressWhenArgumentMatchesName,
InlayHintSettingNames.parameterNamesEnabled,
InlayHintSettingNames.variableTypesEnabled,
InlayHintSettingNames.variableTypesSuppressWhenTypeMatchesName,
InlayHintSettingNames.propertyDeclarationTypesEnabled,
InlayHintSettingNames.functionLikeReturnTypesEnabled,
InlayHintSettingNames.enumMemberValuesEnabled,
];
]);

class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHintsProvider {

Expand Down