You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstload: PageLoad=async({ fetch, parent })=>{const{ uid }=(awaitparent()).session?.user??{};if(!uid){thrownewTypeError("User ID not found");}// Do something};
However, eslint seems not very happy about the parent function reference and throws
Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead. eslint(@typescript-eslint/unbound-method)
/home/projects/stackblitz-starters-1y7qpk/src/routes/sum/+layout.ts
3:42 error Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead @typescript-eslint/unbound-method
/home/projects/stackblitz-starters-1y7qpk/src/routes/sum/+page.ts
3:40 error Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead @typescript-eslint/unbound-method
✖ 2 problems (2 errors, 0 warnings)
* `await parent()` returns data from parent `+layout.js` `load` functions.
* Implicitly, a missing `+layout.js` is treated as a `({ data }) => data` function, meaning that it will return and forward data from parent `+layout.server.js` files.
*
* Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data.
* `await parent()` returns data from parent `+layout.server.js` `load` functions.
*
* Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data.
*/
parent(): Promise<ParentData>;
needs to be changed to parent(this: void): Promise<ParentData>; or parent: () => Promise<ParentData>;, but it seems like this file is auto-generated…
The text was updated successfully, but these errors were encountered:
Describe the bug
My
+page.ts
looks like something like this:However, eslint seems not very happy about the
parent
function reference and throwsDocs on
unbound-method
Reproduction
MRE on Stackblitz
Run
pnpm eslint ./src
to see the errors.Logs
System Info
Severity
annoyance
Additional Information
Patrick in the server mentioned that perhaps
kit/packages/kit/types/index.d.ts
Lines 776 to 782 in 45cb8c5
and
kit/packages/kit/types/index.d.ts
Lines 1201 to 1206 in 45cb8c5
needs to be changed to
parent(this: void): Promise<ParentData>;
orparent: () => Promise<ParentData>;
, but it seems like this file is auto-generated…The text was updated successfully, but these errors were encountered: