Skip to content

Commit 0dbb6ef

Browse files
AVGVSTVS96claude
andcommitted
refactor: improve type naming and add cast justification
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a7ccf7b commit 0dbb6ef

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

package/src/lib/component.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import type { ReactNode } from 'react';
1313
import { forwardRef } from 'react';
1414

1515
/**
16-
* Output formats supported by the component.
17-
* Token output is not supported - use the hook directly for that.
16+
* Output formats the component can render.
17+
* 'tokens' returns raw data requiring custom rendering - use the hook directly.
1818
*/
19-
type ComponentOutputFormat = 'react' | 'html';
19+
type ComponentRenderableFormat = 'react' | 'html';
2020

2121
/**
2222
* Props for the ShikiHighlighter component.
@@ -51,14 +51,13 @@ export interface ShikiHighlighterProps
5151

5252
/**
5353
* Output format for the highlighted code.
54-
* - 'react': Returns React nodes (default, safer)
55-
* - 'html': Returns HTML string (~15-45% faster, requires dangerouslySetInnerHTML)
54+
* - 'react': React nodes (default)
55+
* - 'html': HTML string (faster, uses dangerouslySetInnerHTML)
5656
*
57-
* Note: 'tokens' output is not supported by the component.
58-
* Use the useShikiHighlighter hook directly for token access.
57+
* For 'tokens' output, use useShikiHighlighter hook directly.
5958
* @default 'react'
6059
*/
61-
outputFormat?: ComponentOutputFormat;
60+
outputFormat?: ComponentRenderableFormat;
6261

6362
/**
6463
* Controls the application of default styles to the generated code blocks
@@ -146,7 +145,7 @@ export const createShikiHighlighterComponent = (
146145
},
147146
ref
148147
) => {
149-
const options: HighlighterOptions<ComponentOutputFormat> = {
148+
const options: HighlighterOptions<ComponentRenderableFormat> = {
150149
delay,
151150
transformers,
152151
customLanguages,

package/src/lib/output.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@ export const transformOutput = <F extends OutputFormat>(
114114
options,
115115
isMultiTheme,
116116
};
117+
// Cast okay: registry keys match OutputFormat and each transformer returns its corresponding type
117118
return outputTransformers[format](context) as OutputFormatMap[F];
118119
};

0 commit comments

Comments
 (0)