Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrc-6023 POC static build #236

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
7 changes: 5 additions & 2 deletions app/static/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import type BasicApp from "./components/basic/BasicApp.vue";
import type FitApp from "./components/fit/FitApp.vue";
import type StochasticApp from "./components/stochastic/StochasticApp.vue";

type UnionAppComponent = typeof BasicApp | typeof FitApp | typeof StochasticApp
type IntersectionAppComponent = typeof BasicApp & typeof FitApp & typeof StochasticApp

export function initialiseRouter(
appComponent: typeof BasicApp | typeof FitApp | typeof StochasticApp,
appComponent: UnionAppComponent,
appName: string,
baseUrl: string,
appsPath: string
Expand All @@ -31,7 +34,7 @@ export function initialiseRouter(
component: appComponent,
props: {
initSelectedTab: STATIC_BUILD ? "Options" : undefined
} as Parameters<NonNullable<(typeof appComponent)["setup"]>>["0"]
} as Parameters<NonNullable<IntersectionAppComponent["setup"]>>["0"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line basically gets the type of the first argument of setup function (which is props), so we can be sure that the selected tab exists for every app type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you've done this but it's quite confusing to read! I don't really love invoking the first parameter of setup as a way of getting out of declaring actual props types - it does save you that maintenance overhead but with something of a loss of clarity! Could we at least declare this type above and put a comment on it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure yh, sadly i couldnt actually find a way to extract the prop types any other way from defineComponent type which sucks, feel like they couldve made that easier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed. We've usually just defined the types ourselves in the past. It's boring boilerplate, but it's easy to comprehend...

};

const sessionsRoute: RouteRecordRaw = {
Expand Down
Loading