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

fix(sveltekit): Wrap load when typed explicitly #8049

Conversation

sreetamdas
Copy link
Contributor

@sreetamdas sreetamdas commented May 5, 2023

  • When load is explicitly typed (using LayoutLoad, PageLoad, etc.), auto-instrumentation fails.
  • The SvelteKit docs suggest using the satisfies operator everywhere, but this is not strictly enforced. Prior to support for satisfies in TypeScript 4.9, the docs also suggested using explicit types, and were updated once support was more common. (PR)
  • Update the hasLoadDeclaration regex introduced in feat(sveltekit): Auto-wrap load functions with proxy module #7994 to also check for cases when there is an explicit type.
  • Simplified example of a +layout.tsfile that would be skipped:
     import type { LayoutLoad } from "./$types";
     export const load : LayoutLoad = async () => { return { props: { msg: "hi" } } }
     
     // message when debugging: 
     // Skipping wrapping /src/routes/nested/+layout.ts because it doesn't declare a `load` function

Before submitting a pull request, please take a look at our Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@sreetamdas sreetamdas marked this pull request as ready for review May 5, 2023 05:04
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Hi @sreetamdas thanks for opening this PR! You're absolutely right, I missed this case.
I'm going to merge this PR to unblock folks using explicit typing. In the long run, though, I think we need to replace this regex with an AST check.

@Lms24 Lms24 merged commit 194130e into getsentry:develop May 5, 2023
@Lms24 Lms24 self-assigned this May 5, 2023
@sreetamdas
Copy link
Contributor Author

@Lms24 Thanks! And yep, understood. I'll keep an eye out when you implement it, I'd love to see how that works. 😄

@Lms24
Copy link
Member

Lms24 commented May 5, 2023

Expect this to be released on Monday :)

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.

2 participants