Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions packages/components/src/components/code-block/code-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type CodeBlockProps = {
feedbackButton?: ReactNode;
children?: ReactNode;
copyButtonProps?: CopyToClipboardButtonProps;
isParentCodeGroup?: boolean;
shouldHighlight?: boolean;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant prop declarations in extending interface

Low Severity

Adding isParentCodeGroup and shouldHighlight to CodeBlockProps creates redundancy with BaseCodeBlockProps, which extends CodeBlockProps and re-declares the exact same two properties. Only forceExtract is actually unique to BaseCodeBlockProps. If the types diverge in the future (e.g., one becomes required), the override in BaseCodeBlockProps could silently mask the change.

Fix in Cursor Fix in Web

};

const CodeBlock = function CodeBlock(params: CodeBlockProps) {
Expand All @@ -87,12 +89,10 @@ const CodeBlock = function CodeBlock(params: CodeBlockProps) {
children,
className,
icon,
isSmallText,
hideAskAiButton,
feedbackModalOpen,
anchorRef,
codeBlockTheme = "system",
codeBlockThemeObject,
askAiButton,
feedbackButton,
copyButtonProps,
Expand Down Expand Up @@ -130,7 +130,7 @@ const CodeBlock = function CodeBlock(params: CodeBlockProps) {
textToCopy={codeString}
{...copyButtonProps}
/>
{askAiButton && askAiButton}
{askAiButton && !hideAskAiButton ? askAiButton : null}
</CodeHeader>
) : (
<div
Expand All @@ -143,16 +143,10 @@ const CodeBlock = function CodeBlock(params: CodeBlockProps) {
textToCopy={codeString}
{...copyButtonProps}
/>
{askAiButton && askAiButton}
{askAiButton && !hideAskAiButton ? askAiButton : null}
</div>
)}
<BaseCodeBlock
codeBlockTheme={codeBlockTheme}
codeBlockThemeObject={codeBlockThemeObject}
hideAskAiButton={hideAskAiButton}
isSmallText={isSmallText}
{...params}
/>
<BaseCodeBlock {...params} />
</div>
);
};
Expand Down
Loading