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

Outdated svelte2tsx dependency for @sveltejs/package #12517

Open
lachlancollins opened this issue Jul 29, 2024 · 0 comments
Open

Outdated svelte2tsx dependency for @sveltejs/package #12517

lachlancollins opened this issue Jul 29, 2024 · 0 comments
Labels
pkg:svelte-package Issues related to svelte-package

Comments

@lachlancollins
Copy link
Contributor

Describe the bug

Hi there, I've stumbled across an annoying issue using @sveltejs/package to generate types for svelte 5 components, related to the svelte2tsx semver range. I think this is the best place to post this issue since the change would need to be made in this repo.

Because of the way pnpm works, when @sveltejs/package updates, it does not update indirect dependencies that already match the semver range. The semver range of svelte2tsx is currently "~0.7.0", and hasn't been updated since #11619 (6 months ago).

At some point, the version of svelte2tsx in the TanStack Query repo got installed as v0.7.1. However, there are numerous new releases since then which have improved svelte 5 compatibility. When packaging svelte 5 components with this version of svelte2tsx, it is unable to generate the correct types (all props are unknown).

I can work around this problem by deleting pnpm-lock.yaml, which installs the latest svelte2tsx version (v0.7.13) and generates the correct types. However, I wonder if it would be better to keep svelte2tsx's semver range updated within @sveltejs/package so other library devs don't run into the problem. This could be automatically handled by renovate with the "rangeStrategy": "bump" option - for reference, this is also used by Astro's renovate config.

Reproduction

With svelte2tsx v0.7.1 installed as a dependency of @sveltejs/package, the following component Demo.svelte:

<script lang="ts">
  type Props = {
    foo: string
  }

  let { foo }: Props = $props()
</script>

<div>{foo}</div>

Generates the following type output:

import { SvelteComponent } from "svelte";
declare const __propDef: {
    props: {
        foo: unknown;
    };
    events: {
        [evt: string]: CustomEvent<any>;
    };
    slots: {};
};
export type DemoProps = typeof __propDef.props;
export type DemoEvents = typeof __propDef.events;
export type DemoSlots = typeof __propDef.slots;
export default class Demo extends SvelteComponent<DemoProps, DemoEvents, DemoSlots> {
}
export {};

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 12.49 GB / 15.58 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.11.0 - ~/.volta/tools/image/node/20.11.0/bin/node
    npm: 10.2.5 - ~/.volta/tools/image/npm/10.2.5/bin/npm
    pnpm: 9.5.0 - ~/.volta/bin/pnpm
  npmPackages:
    @sveltejs/package: ^2.3.1 => 2.3.1 
    @sveltejs/vite-plugin-svelte: ^4.0.0-next.5 => 4.0.0-next.5 
    svelte: ^5.0.0-next.200 => 5.0.0-next.200

Severity

serious, but I can work around it

Additional Information

No response

@benmccann benmccann added the pkg:svelte-package Issues related to svelte-package label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:svelte-package Issues related to svelte-package
Projects
None yet
Development

No branches or pull requests

2 participants