1
- export type Window = typeof window
2
- export type Location = typeof window . location
3
- export type History = typeof window . history
1
+ export type Window = {
2
+ location : Location ,
3
+ history : History ,
4
+ addEventListener ( type : 'popstate' , listener : ( e : PopStateEvent ) => void ) : void
5
+ removeEventListener ( type : 'popstate' , listener : ( e : PopStateEvent ) => void ) : void
6
+ }
7
+ export type Location = {
8
+ pathname : string
9
+ }
10
+ export type History = {
11
+ replaceState ( data : any , title : string , url : string ) : void
12
+ pushState ( data : any , title : string , url : string ) : void
13
+ back ( ) : void
14
+ }
4
15
5
16
export type State = { path ?: string , fullPath ?: string }
6
17
@@ -57,7 +68,7 @@ export function joinPath(a:string,b: string): string {
57
68
}
58
69
59
70
function Superhistory ( {
60
- _window = globalThis . window ,
71
+ _window= globalThis . window as any as Window ,
61
72
onChange = ( ) => { } ,
62
73
} : Attrs = { } ) : InternalInstance {
63
74
const children = new Set < InternalInstance > ( )
@@ -78,7 +89,8 @@ function Superhistory({
78
89
79
90
function go ( path : string , options : { replace ?: boolean } = { } ) {
80
91
path = normalizePath ( path )
81
- _window . history [ `${ options . replace ? 'replace' : 'push' } State` ] (
92
+
93
+ _window . history [ options . replace ? 'replaceState' : 'pushState' ] (
82
94
null ,
83
95
'' ,
84
96
path ,
0 commit comments