kit icon indicating copy to clipboard operation
kit copied to clipboard

fix: correctly include ambient types from adapters

Open teemingc opened this issue 1 year ago • 4 comments

part of closing https://github.com/sveltejs/kit/pull/11731

While investigating https://github.com/sveltejs/kit/pull/11731 , I found that the ambient types from adapters weren't showing up when I tried installing the cloudflare, vercel, and node adapters in a fresh project and tried to access the autocomplete on event.platform.

This PR does the following:

~* includes the svelte.config.js file in the generated tsconfig so that when the svelte.config.js file imports the adapter, the ambient types are included for the whole project.~ EDIT: separated into https://github.com/sveltejs/kit/pull/12090

  • references the worker types in the cloudflare adapters so that when the adapter is used, the project can access those types.
  • standardises the naming of the files containing the internal adapter types and the ambient types we want included in the user's project when they add the adapter to the svelte config.
  • includes the vercel and node ambient types in the package.json files array.

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

  • [x] 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
  • [x] This message body should clearly illustrate what problems it solves.
  • [ ] Ideally, include a test that fails without this PR but passes with it.

Tests

  • [x] Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • [x] 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

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

teemingc avatar Apr 07 '24 08:04 teemingc

🦋 Changeset detected

Latest commit: 6242385918309e174a34cf9761f396412aa39d1b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sveltejs/adapter-vercel Patch
@sveltejs/adapter-node Patch

Not sure what this means? Click here to learn what changesets are.

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

changeset-bot[bot] avatar Apr 07 '24 08:04 changeset-bot[bot]

Inclusion of the Svelte config was reverted in #11908 because it's a breaking change strictly speaking. Is it ok to hold off from doing this until 3.0?

dummdidumm avatar Apr 07 '24 12:04 dummdidumm

Inclusion of the Svelte config was reverted in #11908 because it's a breaking change strictly speaking. Is it ok to hold off from doing this until 3.0?

Oh whoops. I didn’t realise it was something we already tried to do before.

Yeah, I think it’s fine to wait for 3.0 for this. It has an easy workaround (just include the types or reference the adapter in a declaration file). Maybe I can split the ambient declaration changes and the svelte config inclusion into separate PRs?

teemingc avatar Apr 07 '24 13:04 teemingc

note: it was suggested to not include the cloudflare types because they pollute the ambient types namespace.

teemingc avatar Jun 08 '24 16:06 teemingc

@benmccann is this a breaking change because of the additional types in the ambient namespace?

teemingc avatar Jul 23 '24 15:07 teemingc

Oh, I was confused because of the prior conversation on this PR (which seems to refer to a change that was dropped from this PR and moved to https://github.com/sveltejs/kit/pull/12090) and because this PR was in the 3.0 milestone. I've taken it off the 3.0 milestone and removed the breaking change label

benmccann avatar Jul 23 '24 18:07 benmccann

preview: https://svelte-dev-git-preview-kit-12088-svelte.vercel.app/

this is an automated message

Rich-Harris avatar Dec 12 '24 04:12 Rich-Harris