- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Closed as not planned
Description
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
Metadata
Metadata
Assignees
Labels
No labels