Skip to content

Commit 5a177af

Browse files
committed
fix(twoslash): improve types
1 parent 3b34a1f commit 5a177af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/twoslash/src/core.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { ShikiTransformer } from '@shikijs/core'
77
import type { Element, ElementContent, Text } from 'hast'
88

99
import { splitTokens } from '@shikijs/core'
10-
import type { TransformerTwoslashOptions, TwoslashRenderer, TwoslashShikiReturn } from './types'
10+
import type { TransformerTwoslashOptions, TwoslashRenderer, TwoslashShikiFunction } from './types'
1111
import { ShikiTwoslashError } from './error'
1212

1313
export * from './types'
@@ -22,10 +22,8 @@ export function defaultTwoslashOptions(): TwoslashExecuteOptions {
2222
}
2323
}
2424

25-
export type TwoslashFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) => TwoslashShikiReturn
26-
2725
export function createTransformerFactory(
28-
defaultTwoslasher: TwoslashFunction,
26+
defaultTwoslasher: TwoslashShikiFunction,
2927
defaultRenderer?: TwoslashRenderer,
3028
) {
3129
return function transformerTwoslash(options: TransformerTwoslashOptions = {}): ShikiTransformer {

packages/twoslash/src/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { NodeCompletion, NodeError, NodeHighlight, NodeHover, NodeQuery, NodeTag, TwoslashOptions, TwoslashReturn, twoslasher } from 'twoslash'
1+
import type { NodeCompletion, NodeError, NodeHighlight, NodeHover, NodeQuery, NodeTag, TwoslashExecuteOptions, TwoslashOptions, TwoslashReturn } from 'twoslash'
22
import type { CodeToHastOptions, ShikiTransformerContext } from '@shikijs/core'
33
import type { Element, ElementContent, Text } from 'hast'
44

@@ -8,6 +8,8 @@ export type TwoslashShikiReturn =
88
meta?: Partial<Pick<TwoslashReturn['meta'], 'extension'>>
99
}
1010

11+
export type TwoslashShikiFunction = (code: string, lang?: string, options?: TwoslashExecuteOptions) => TwoslashShikiReturn
12+
1113
declare module '@shikijs/core' {
1214
interface ShikiTransformerContextMeta {
1315
twoslash?: TwoslashShikiReturn
@@ -37,7 +39,7 @@ export interface TransformerTwoslashOptions {
3739
/**
3840
* Custom instance of twoslasher function
3941
*/
40-
twoslasher?: typeof twoslasher
42+
twoslasher?: TwoslashShikiFunction
4143
/**
4244
* Options to pass to twoslash
4345
*/

0 commit comments

Comments
 (0)