Skip to content

Commit

Permalink
uglier, but no double check
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Feb 3, 2020
1 parent e30ed93 commit 5fb7d67
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/routers/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ export default function patternRouter<TRouteState extends object = UiState>({
decode: decodeURIComponent,
});
const pathParameters = parse(pattern)
.filter(token => typeof token === 'object')
// TODO: why do I need to guard twice here? TS complained
.map(token => (typeof token === 'object' ? token.name : ''));
.filter(
<TKey>(token: TKey | string): token is TKey => typeof token !== 'string'
)
.map(token => token.name);

let onPopState: (event: PopStateEvent) => void | undefined;
let writeTimer: number | undefined;
Expand Down

0 comments on commit 5fb7d67

Please sign in to comment.