TypeScript load function example
See original GitHub issueDescribe the problem
It took me a long time to figure out how to write a TypeScript load
function for __error.svelte
Describe the proposed solution
Include an example 😃
import type { ErrorLoadInput, LoadOutput } from "@sveltejs/kit";
export async function load({
error,
status,
}: ErrorLoadInput): Promise<LoadOutput> {
return {
props: {
title: `${status}: ${error.message}`,
stack: error.stack,
},
};
}
Alternatives considered
Don’t include an example 😦
Importance
nice to have
Additional Information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
TypeScript - Calling a Function - Tutorialspoint
TypeScript - Calling a Function, A function must be called so as to execute it. This process is termed as function invocation.
Read more >Documentation - Modules - TypeScript
Modules import one another using a module loader. ... Any declaration (such as a variable, function, class, type alias, ... Some samples to...
Read more >How To Use Functions in TypeScript - DigitalOcean
Creating Typed Functions In this section, you will create functions in TypeScript, and then add type information to them. In this example, sum ......
Read more >Importing functions in typescript - Stack Overflow
An example: // global.ts export function abc() { } // main.ts import { abc } from "./global" abc();. I suggest to read the...
Read more >svelte kit load functions in typekit : r/sveltejs - Reddit
Wondering if I can add type definitions to my load function if at all possible? ... I built a MacOS Clone with TypeScript...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can import the
Load
type:But I agree that there should be an example for this.
Yeah. It works but I think we should add some docs for Typescript. Not only for javascript.