Skip to content

Update types.ts #1820

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update types.ts #1820

wants to merge 1 commit into from

Conversation

huseeiin
Copy link
Contributor

add types for routes & assets in PageEvent

PR Checklist

Please check if your PR fulfills the following requirements:

  • Addresses an existing open issue: fixes #000
  • Tests for the changes have been added (for bug fixes / features)

What is the current behavior?

What is the new behavior?

Other information

add types for routes & assets in PageEvent
Copy link

changeset-bot bot commented Feb 20, 2025

⚠️ No Changeset found

Latest commit: 7869215

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Feb 20, 2025

Deploy Preview for solid-start-landing-page failed. Why did it fail? →

Name Link
🔨 Latest commit 7869215
🔍 Latest deploy log https://app.netlify.com/sites/solid-start-landing-page/deploys/67b784dedf3f430008c0db0b

@@ -1,81 +1,92 @@
import type { JSX } from "solid-js";
import { RequestEvent } from "solid-js/web";
import { HTTPEvent } from "vinxi/http";
import { RouteDefinition } from "@solidjs/router";
Copy link
Member

Choose a reason for hiding this comment

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

Hmm. This challenge the router-agnostic principle of solid-start

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if that's why it was previously any, then i'm ok with it remaining this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could make the type extendable like how Tanstack Table does with its meta. Relevant code.

declare module '@tanstack/table-core' {
  interface TableMeta<TData extends RowData> {
    foo: string
  }
}

So a solid-start user's code could be

import { RouteDefinition } from "@solidjs/router";

export interface Route extends RouteDefinition {
    page: boolean;
    filePath: string;
    id: string;
    $component: {
        src: string;
        import: () => Promise<any>;
    };
}

And solid-start's types.ts would need to do something like

export interface PageEventRoutes {}

export interface PageEvent extends RequestEvent {
    manifest: any;
    assets: Asset[];
    routes: PageEventRoutes[];
   // remainder of def
}

Giving it an explicit named type would make it easier to extend, I think? idk haven't tested any of this, just theorycrafting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants