11import type { Token } from "../types"
2- import type { Token as PrismToken } from "prismjs"
2+ import type { Token as PrismToken , TokenStream } from "prismjs"
33
44const newlineRe = / \r \n | \r | \n /
55
@@ -33,7 +33,7 @@ const appendTypes = (types: string[], add: string[] | string): string[] => {
3333// are always of type "plain".
3434// This is not recursive to avoid exceeding the call-stack limit, since it's unclear
3535// how nested Prism's tokens can become
36- const normalizeTokens = ( tokens : Array < PrismToken | string > ) : Token [ ] [ ] => {
36+ const normalizeTokens = ( tokens : ( PrismToken | string ) [ ] ) : Token [ ] [ ] => {
3737 const typeArrStack : string [ ] [ ] = [ [ ] ]
3838 const tokenArrStack = [ tokens ]
3939 const tokenArrIndexStack = [ 0 ]
@@ -47,7 +47,7 @@ const normalizeTokens = (tokens: Array<PrismToken | string>): Token[][] => {
4747 while (
4848 ( i = tokenArrIndexStack [ stackIndex ] ++ ) < tokenArrSizeStack [ stackIndex ]
4949 ) {
50- let content : any
50+ let content : TokenStream
5151 let types = typeArrStack [ stackIndex ]
5252 const tokenArr = tokenArrStack [ stackIndex ]
5353 const token = tokenArr [ i ]
@@ -70,7 +70,7 @@ const normalizeTokens = (tokens: Array<PrismToken | string>): Token[][] => {
7070 if ( typeof content !== "string" ) {
7171 stackIndex ++
7272 typeArrStack . push ( types )
73- tokenArrStack . push ( content )
73+ tokenArrStack . push ( content as PrismToken [ ] )
7474 tokenArrIndexStack . push ( 0 )
7575 tokenArrSizeStack . push ( content . length )
7676 continue
0 commit comments