Init script now uses unknown for route props type

This commit is contained in:
Konstantin Wohlwend 2024-11-15 22:27:42 +01:00
parent f45348462e
commit f3f5e6c046
4 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import { StackHandler } from "@stackframe/stack";
import { stackServerApp } from "@/stack";
import { StyledLink } from "@/components/link";
export default function Handler(props: any) {
export default function Handler(props: unknown) {
const extraInfo = <>
<p className="text-xs">By signing in, you agree to the</p>
<p className="text-xs"><StyledLink href="https://www.iubenda.com/privacy-policy/19290387/cookie-policy">Terms of Service</StyledLink> and <StyledLink href="https://www.iubenda.com/privacy-policy/19290387">Privacy Policy</StyledLink></p>

View File

@ -85,7 +85,7 @@ We recommend using our **setup wizard**, which will automatically detect your pr
import { StackHandler } from "@stackframe/stack";
import { stackServerApp } from "@/stack";
export default function Handler(props: any) {
export default function Handler(props: unknown) {
return <StackHandler fullPage app={stackServerApp} routeProps={props} />;
}
```

View File

@ -232,7 +232,7 @@ async function main() {
await writeFileIfNotExists(
handlerPath,
`import { StackHandler } from "@stackframe/stack";\nimport { stackServerApp } from "../../../stack";\n\nexport default function Handler(props${
handlerFileExtension.includes("ts") ? ": any" : ""
handlerFileExtension.includes("ts") ? ": unknown" : ""
}) {\n${ind}return <StackHandler fullPage app={stackServerApp} routeProps={props} />;\n}\n`
);
await writeFileIfNotExists(

View File

@ -44,20 +44,20 @@ export default async function StackHandler<HasTokenStore extends boolean>(props:
} & (
| Partial<RouteProps>
| {
routeProps: RouteProps,
routeProps: RouteProps | unknown,
}
)): Promise<any> {
if (!("routeProps" in props)) {
console.warn(next15DeprecationWarning);
}
const routeProps = "routeProps" in props ? props.routeProps : pick(props, ["params", "searchParams"] as any);
const routeProps = "routeProps" in props ? props.routeProps as RouteProps : pick(props, ["params", "searchParams"] as any);
const params = await routeProps.params;
const searchParams = await routeProps.searchParams;
if (!params?.stack) {
return (
<MessageCard title="Invalid Stack Handler Setup" fullPage={props.fullPage}>
<p>Can't use {"<StackHandler />"} at this location. Make sure that the file is in a folder called [...stack].</p>
<p>Can't use {"<StackHandler />"} at this location. Make sure that the file is in a folder called [...stack] and you are passing the routeProps prop.</p>
</MessageCard>
);
}