Skip to content

Commit 5d73792

Browse files
committed
fix(compact): improve types export
1 parent 02d7b50 commit 5d73792

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

packages/shikiji-compat/src/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import type {
55
CodeOptionsMultipleThemes,
66
CodeOptionsSingleTheme,
77
CodeToHastOptionsCommon,
8-
IRawGrammar,
98
LanguageRegistration,
9+
RawGrammar,
1010
StringLiteralUnion,
1111
ThemeRegistration,
1212
ThemeRegistrationRaw,
13+
ThemedToken,
1314
} from 'shikiji'
1415

1516
export interface LineOption {
@@ -35,6 +36,8 @@ export interface HighlighterOptions extends BundledHighlighterOptions<BuiltinLan
3536
export type IThemeRegistration = ThemeRegistrationRaw | ThemeRegistration | StringLiteralUnion<BuiltinTheme>
3637

3738
export interface IShikiTheme extends ThemeRegistration {}
39+
export interface IThemedToken extends ThemedToken {}
40+
export interface IRawGrammar extends RawGrammar {}
3841

3942
export interface ILanguageRegistration extends LanguageRegistration {
4043
grammar?: IRawGrammar

packages/shikiji/src/types.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
import type { IGrammar, IRawGrammar, IRawTheme } from 'vscode-textmate'
1+
import type {
2+
IGrammar as Grammar,
3+
IRawGrammar as RawGrammar,
4+
IRawTheme as RawTheme,
5+
} from 'vscode-textmate'
26
import type { IRawThemeSetting } from 'vscode-textmate/release/theme'
37
import type { Element, Root } from 'hast'
48
import type { bundledThemes } from './themes'
59
import type { bundledLanguages } from './assets/langs'
610
import type { FontStyle } from './core/stackElementMetadata'
711
import type { OnigurumaLoadOptions } from './oniguruma'
812

9-
export { IRawGrammar, IGrammar, FontStyle }
13+
export {
14+
Grammar,
15+
RawGrammar,
16+
FontStyle,
17+
// TODO: move these in the next major version
18+
Grammar as IGrammar,
19+
RawGrammar as IRawGrammar,
20+
}
1021

1122
export type BuiltinLanguage = keyof typeof bundledLanguages
1223
export type BuiltinTheme = keyof typeof bundledThemes
@@ -42,7 +53,7 @@ export interface ShikiContext {
4253
}
4354

4455
getTheme(name: string | ThemeRegistration | ThemeRegistrationRaw): ThemeRegistration
45-
getLangGrammar(name: string): IGrammar
56+
getLangGrammar(name: string): Grammar
4657

4758
getLoadedThemes(): string[]
4859
getLoadedLanguages(): string[]
@@ -155,7 +166,7 @@ export interface BundledHighlighterOptions<L extends string, T extends string> {
155166
langAlias?: Record<string, StringLiteralUnion<L>>
156167
}
157168

158-
export interface LanguageRegistration extends IRawGrammar {
169+
export interface LanguageRegistration extends RawGrammar {
159170
name: string
160171
scopeName: string
161172
displayName?: string
@@ -290,9 +301,7 @@ export type CodeToHastOptions<Languages extends string = string, Themes extends
290301
& CodeOptionsThemes<Themes>
291302
& CodeOptionsMeta
292303

293-
export interface ThemeRegistrationRaw extends IRawTheme {
294-
295-
}
304+
export interface ThemeRegistrationRaw extends RawTheme {}
296305

297306
export interface ThemeRegistration extends ThemeRegistrationRaw {
298307
/**

0 commit comments

Comments
 (0)