Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c545a1a

Browse files
committed
feat: Improve typings and shim
1 parent ccf795e commit c545a1a

File tree

3 files changed

+14
-41
lines changed

3 files changed

+14
-41
lines changed

‎README.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ export default {
182182
| navigatedFrom | - | This event is tricky to control for developers. There is no exact mapping of it in the router. For store state cleanup use build-in meta dispatcher instead. For component state you could opt for using `beforeRouteLeave()`. |
183183

184184
## TypeScript Support
185-
If you need a TS support and it's not detected in your project for some reason, you can use [typings/shims.vue.d.ts](https://github.com/MattCCC/nativescript-vue-router-extended/blob/master/src/typings/shims-vue.d.ts) to bring proper support in .vue files.
186-
187-
Assuming that your node_modules/ directory is on same level, you can specify following line in your `references.d.ts` file:
185+
If you need a TS support and it's not detected automatically in your project for some reason, you can use [typings/shims.vue.d.ts](https://github.com/MattCCC/nativescript-vue-router-extended/blob/master/src/typings/shims-vue.d.ts) to bring proper support in .vue files. You can specify it in your `shims.vue.d.ts` file (attention! Please ensure that path is relative to your node_modules directory):
188186
```
189187
/// <reference path="./node_modules/nativescript-vue-router-extended/typings/shims-vue.d.ts" />
190188
```

‎src/typings/router-service.d.ts‎

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {
22
RouterOptions,
33
} from 'vue-router';
4+
import {
5+
NavigationEntryVue,
6+
} from 'nativescript-vue';
47

58
export type RouteChildren = Route;
69
export type ErrorCallback = Error | ((...args: any[]) => void);
@@ -18,48 +21,23 @@ export interface NSVueRouterOptions extends RouterOptions {
1821
history?: string;
1922
}
2023

21-
export interface Route extends RouteOptions {
22-
path: string;
23-
name?: string;
24-
component?: Component;
25-
children?: RouteChildren;
26-
27-
beforeRouteEnter?: (to: Route, from: Route, next?: (vm: any) => void) => boolean;
28-
beforeRouteLeave?: (to: Route, from: Route, next?: (vm: any) => void) => boolean;
29-
}
30-
31-
export interface RouteOptions {
24+
export interface RouteOptions extends NavigationEntryVue {
3225
/**
3326
* List of route meta information
3427
* Can contain a store object with action names as keys and payload as values.
3528
* These actions will be dispatched once a particular route is navigated to
3629
*/
3730
meta?: Record<string, any>;
31+
}
3832

39-
/**
40-
* Animation duration when switching a route
41-
*/
42-
duration?: number;
43-
44-
/**
45-
* Allows to pass props directly in $routeTo
46-
*/
47-
props?: Record<string, any>;
48-
49-
/**
50-
* Same as props, used internally for proper NS navigation support
51-
*/
52-
context?: Record<string, any>;
53-
54-
/**
55-
* Whether to clear previous records from the history
56-
*/
57-
clearHistory?: boolean;
33+
export interface Route extends RouteOptions {
34+
path: string;
35+
name?: string;
36+
component?: Component;
37+
children?: RouteChildren;
5838

59-
/**
60-
* NativeScript compatible transition object
61-
*/
62-
transition?: Record<string, any>;
39+
beforeRouteEnter?: (to: Route, from: Route, next?: (vm: any) => void) => boolean;
40+
beforeRouteLeave?: (to: Route, from: Route, next?: (vm: any) => void) => boolean;
6341
}
6442

6543
export interface RouterServiceOptions {

‎src/typings/shims-vue.d.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ import type {
66
} from "vue-router/dist/vue-router.d";
77
import type { RouterService } from "nativescript-vue-router-extended/router-service";
88

9-
declare module "*.vue" {
10-
export default Vue;
11-
}
12-
139
declare module "vue/types/vue" {
1410
interface Vue {
11+
$route: Route;
1512
$router: RouterService;
1613
$routeTo(route: Route | string, options?: RouteOptions): void;
1714
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /