Commit f9543da
docs: type the external redirect guard (#33887)
`externalRedirect()` passed its guard to `canActivate` as an inline
arrow function. `canActivate` accepts `CanActivateFn` as well as the
deprecated class-based guards, typed as `ProviderToken<any>`. Any
function also matches `ProviderToken<any>`, so TypeScript didn't check
the inline guard against `CanActivateFn`. For example, a guard returning
a number would still compile.
This declares the guard as a `CanActivateFn` before passing it to
`canActivate`, so its return value is type checked. The behavior is
unchanged. A comment explains why the type is needed, so it isn't
inlined again later.
(cherry picked from commit 1543543)1 parent 8a2ffd1 commit f9543da
1 file changed
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
0 commit comments