Skip to content

Commit

Permalink
updated application.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
uguraslan committed May 7, 2024
1 parent d600b01 commit 73cd27e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
19 changes: 9 additions & 10 deletions src/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import {default as Component} from './component'
import ComponentInstance from './component'

declare namespace Application {

Expand Down Expand Up @@ -85,10 +84,6 @@ declare namespace Application {
politeness?: 'off' | 'polite' | 'assertive'
}

function Application(
config: Application.ApplicationConfig
) : Application.ApplicationInstance

type RequireAtLeastOne<T> = {
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
}[keyof T]
Expand All @@ -105,7 +100,7 @@ declare namespace Application {
/**
* Component to load when activating the route
*/
component: typeof ComponentInstance,
component: Component,
/**
* Transition configuration for the route
*/
Expand Down Expand Up @@ -143,9 +138,9 @@ declare namespace Application {
}
}

export interface ApplicationInstance extends ComponentInstance {}
export interface ApplicationInstance extends Component.ComponentInstance {}

export interface ApplicationConfig extends Component.ComponentConfig<Component.Props extends string, Component.Watch, Component.Computed, Component.Hooks, Component.Input, Component.State, Component.Methods> {
export interface ApplicationConfig<Props extends string, S, M> extends Component.ComponentConfig<Props, S, M> {
/**
* Routes definition
*
Expand All @@ -168,8 +163,12 @@ declare namespace Application {
*
* Root App component
*/
declare function Application(
config: Application.ApplicationConfig
declare function Application<
Props extends string,
S extends Component.State,
M extends Component.Methods
>(
config: Application.ApplicationConfig<Props, S, M>
) : Application.ApplicationInstance

export default Application;
19 changes: 10 additions & 9 deletions src/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,18 @@ declare namespace Component {
* Route object
*/
interface Route {
path: string;
params: Record<string, string>;
path: string,
params: Record<string, string>,
options?: {
inHistory?: boolean;
keepAlive?: boolean;
[key: string]: any;
};
data?: Record<string, any>;
inHistory?: boolean,
keepAlive?: boolean,
[key: string]: any,
},
data?: Record<string, any>,
component?: (args: { props: any }, holder: any, context: any) => Promise<any>,
hooks?: {
before?: (route: Route, previousRoute: Route) => Promise<string | Route | void>;
};
before?: (route: Route, previousRoute: Route) => Promise<string | Route | void>,
}
}


Expand Down

0 comments on commit 73cd27e

Please sign in to comment.