Repository: microsoft/TypeScript
File: src/services/inlayHints.ts (TypeScript)

Code before:
                    break;
                case SyntaxKind.TypePredicate:
                    Debug.assertNode(node, isTypePredicateNode);
                    if (node.assertsModifier) {
                        parts.push({ text: "asserts " });
                    }
                    visitForDisplayParts(node.parameterName);
                    if (node.type) {
                        parts.push({ text: " is " });
                        visitForDisplayParts(node.type);
                    }
                    break;
                case SyntaxKind.TypeReference:
                    Debug.assertNode(node, isTypeReferenceNode);
                    visitForDisplayParts(node.typeName);
                    if (node.typeArguments) {
                        parts.push({ text: "<" });
                        visitDisplayPartList(node.typeArguments, ", ");
                        parts.push({ text: ">" });
                    }
                    break;
                case SyntaxKind.TypeParameter:
                    Debug.assertNode(node, isTypeParameterDeclaration);
                    if (node.modifiers) {
                        visitDisplayPartList(node.modifiers, " ");
                    }
                    visitForDisplayParts(node.name);
                    if (node.constraint) {
                        parts.push({ text: " extends " });
                        visitForDisplayParts(node.constraint);
                    }
                    if (node.default) {
                        parts.push({ text: " = " });
                        visitForDisplayParts(node.default);
                    }
                    break;
                case SyntaxKind.Parameter:
                    Debug.assertNode(node, isParameter);
                    if (node.modifiers) {
                        visitDisplayPartList(node.modifiers, " ");
                    }
                    if (node.dotDotDotToken) {
                        parts.push({ text: "..." });
                    }
                    visitForDisplayParts(node.name);
                    if (node.questionToken) {
                        parts.push({ text: "?" });
                    }
                    if (node.type) {
                        parts.push({ text: ": " });
                        visitForDisplayParts(node.type);

Review comment (refactor):
This code duplicates the exact same logic that already exists in the `visitForDisplayParts` function for `SyntaxKind.TypeParameter` case (line 584-586 in context). The spacing logic should be handled consistently in one place rather than duplicated.

Code after:
                    break;
                case SyntaxKind.TypePredicate:
                    Debug.assertNode(node, isTypePredicateNode);
                    if (node.assertsModifier) {
                        parts.push({ text: "asserts " });
                    }
                    visitForDisplayParts(node.parameterName);
                    if (node.type) {
                        parts.push({ text: " is " });
                        visitForDisplayParts(node.type);
                    }
                    break;
                case SyntaxKind.TypeReference:
                    Debug.assertNode(node, isTypeReferenceNode);
                    visitForDisplayParts(node.typeName);
                    if (node.typeArguments) {
                        parts.push({ text: "<" });
                        visitDisplayPartList(node.typeArguments, ", ");
                        parts.push({ text: ">" });
                    }
                    break;
                case SyntaxKind.TypeParameter:
                    Debug.assertNode(node, isTypeParameterDeclaration);
                    if (node.modifiers) {
                        visitDisplayPartList(node.modifiers, " ");
                        parts.push({ text: " " });
                    }
                    visitForDisplayParts(node.name);
                    if (node.constraint) {
                        parts.push({ text: " extends " });
                        visitForDisplayParts(node.constraint);
                    }
                    if (node.default) {
                        parts.push({ text: " = " });
                        visitForDisplayParts(node.default);
                    }
                    break;
                case SyntaxKind.Parameter:
                    Debug.assertNode(node, isParameter);
                    if (node.modifiers) {
                        visitDisplayPartList(node.modifiers, " ");
                        parts.push({ text: " " });
                    }
                    if (node.dotDotDotToken) {
                        parts.push({ text: "..." });
                    }
                    visitForDisplayParts(node.name);
                    if (node.questionToken) {
                        parts.push({ text: "?" });
                    }
                    if (node.type) {