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

Docs: Update type-casting of "self" without re-declaration in service-worker #13624

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aawnu
Copy link

@aawnu aawnu commented Mar 21, 2025

I don't understand the necessity to abstract self in the serviceworker when other frameworks and wrappers show you how to type-define self without re-declaring it. This also simplifies the conversion from another framework to sveltekit without having to update self-references to sw.

You are free to discard this proposal as I did not find it necessary to have a longer discussion in issues for such a small change that might simplify things for new-comers. I did pre-check issues for pwa and self first to see if this was already in debate.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Mar 21, 2025

⚠️ No Changeset found

Latest commit: d967b94

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot
Copy link

@benmccann benmccann added the documentation Improvements or additions to documentation label Mar 21, 2025
@benmccann
Copy link
Member

Looks like this was added in #8508. I'm not much of a TypeScript expert, but if I think the description for that PR explains why it was done

@aawnu
Copy link
Author

aawnu commented Mar 21, 2025

Looks like this was added in #8508. I'm not much of a TypeScript expert, but if I think the description for that PR explains why it was done

I am making a direct declare in the file and not a types file. It should not define self outside this file in either jsDoc or Typescript. I have no cases of this in VSCode at least.

src/
- routes/
-- +page.ts // "self" is still "Window & typeof globalThis"
-- +page.server.ts // "self" is still "Window & typeof globalThis"
- service-worker/
-- index.ts // "self" is type-declared as "ServiceWorkerGlobalScope"
-- another.ts // "self" is still "Window & typeof globalThis"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants