Skip to content

Commit f01e90f

Browse files
committed
fix ts error
1 parent 863eb1d commit f01e90f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

packages/nextjs/taro/src/internal/taroApp.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import type {TaroPage, CustomRoutes} from '../_util/typings'
55

66
function isAbsoluteUrl(url?: string): boolean {
77
if (!url) {
8-
return false;
8+
return false
99
}
10-
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
10+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url)
1111
}
1212

1313
class TaroApp {
@@ -39,8 +39,8 @@ class TaroApp {
3939

4040
navigateTo: typeof swan.navigateTo = ({url, success, fail, complete}) => {
4141
if (!Router.router) {
42-
fail()
43-
complete()
42+
fail?.()
43+
complete?.()
4444
return
4545
}
4646

@@ -62,31 +62,31 @@ class TaroApp {
6262
route: urlObj.pathname
6363
}
6464
this.pageStack.push(page)
65-
success()
65+
success?.()
6666
})
6767
.catch(fail)
6868
.finally(complete)
6969
}
7070

7171
navigateBack: typeof swan.navigateBack = ({success, fail, complete}) => {
7272
if (!Router.router) {
73-
fail()
74-
complete()
73+
fail?.()
74+
complete?.()
7575
return
7676
}
7777

7878
// Next.js internal router apis aren't support to go back twice or many times.
7979
// https://github.com/vercel/next.js/discussions/18333
8080
Router.router.back()
8181
this.pageStack.pop()
82-
success()
83-
complete()
82+
success?.()
83+
complete?.()
8484
}
8585

8686
redirectTo: typeof swan.redirectTo = ({url, complete, fail, success}) => {
8787
if (!Router.router) {
88-
fail()
89-
complete()
88+
fail?.()
89+
complete?.()
9090
return
9191
}
9292

@@ -105,16 +105,16 @@ class TaroApp {
105105
}
106106
this.pageStack.pop()
107107
this.pageStack.push(page)
108-
success()
108+
success?.()
109109
})
110110
.catch(fail)
111111
.finally(complete)
112112
}
113113

114114
reLaunch: typeof swan.reLaunch = ({url, complete, fail, success}) => {
115115
if (!Router.router) {
116-
fail()
117-
complete()
116+
fail?.()
117+
complete?.()
118118
return
119119
}
120120

@@ -132,7 +132,7 @@ class TaroApp {
132132
route: urlObj.pathname
133133
}
134134
this.pageStack = [page]
135-
success()
135+
success?.()
136136
})
137137
.catch(fail)
138138
.finally(complete)

0 commit comments

Comments
 (0)