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

server functions #12631

Closed
huseeiin opened this issue Aug 31, 2024 · 3 comments
Closed

server functions #12631

huseeiin opened this issue Aug 31, 2024 · 3 comments

Comments

@huseeiin
Copy link
Contributor

huseeiin commented Aug 31, 2024

Describe the problem

I'm always frustrated when i call an endpoint from client and all the typesafety goes away

<button
  on:click={async () => {
    const res = await fetch("/api/data");
    const data = await res.json();
    // const data: any
  }}>Get stuff</button
>

Describe the proposed solution

like astro, and solidstart, i want a feature that enables me to call server-side functions safely:

<script>
  // $lib/server/index.ts

  function getStuff() {
    return { hello: "world" };
  }

  import { getStuff } from "$lib/server";
</script>

<button
  on:click={() => {
    getStuff();
    // getStuff(): { hello: string; }
  }}>Get stuff</button
>

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@eltigerchino
Copy link
Member

closing as duplicate of #9579

@eltigerchino eltigerchino closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
@huseeiin
Copy link
Contributor Author

huseeiin commented Sep 2, 2024

closing as duplicate of #9579

the issue you mentioned argues to remove form actions. are you sure my issue aligns with that? that is a huge breaking change that i don't support.

@eltigerchino
Copy link
Member

closing as duplicate of #9579

the issue you mentioned argues to remove form actions. are you sure my issue aligns with that? that is a huge breaking change that i don't support.

Sorry, I linked the wrong issue. At the back of my ahead I knew there was an existing issue but I couldn't find it.
I believe this is the one #647 . You might also be interested in #11108 which is draft PR implementing this feature.

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

No branches or pull requests

2 participants