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

svelte-package: svelte-5: Using ComponentConstructorOptions in svelte.d.ts after running svelte-package #12380

Closed
shinokada opened this issue Jun 21, 2024 · 4 comments

Comments

@shinokada
Copy link

Describe the bug

After running pnpm package, and checking a created svelte.d.ts file, it uses ComponentConstructorOptions with stroke line on VSCode.

'ComponentConstructorOptions' is deprecated.ts(6385)
index.d.ts(3, 5): The declaration was marked as deprecated here.

image

Reproduction

Create a sample component, lib/Mycompo.svelte:

<script lang="ts">
  interface Props {
    firstName: string;
    lastName: string;
  }
  let { firstName, lastName }: Props = $props();
</script>

<p>
  Hello {firstName} {lastName}
</p>

In lib/index.ts:

export { default as MyCompo } from './MyCompo.svelte'

Run pnpm package and check dist/MyCompo.svelte.d.ts

Logs

No response

System Info

System:
    OS: macOS 14.6
    CPU: (10) arm64 Apple M2 Pro
    Memory: 43.16 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    pnpm: 9.4.0 - /opt/homebrew/bin/pnpm
    bun: 1.1.8 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.62
    Edge: 126.0.2592.68
    Safari: 17.6
  npmPackages:
    @sveltejs/adapter-auto: ^3.2.2 => 3.2.2 
    @sveltejs/kit: ^2.5.17 => 2.5.17 
    @sveltejs/package: ^2.3.2 => 2.3.2 
    @sveltejs/vite-plugin-svelte: ^3.1.1 => 3.1.1 
    svelte: 5.0.0-next.162 => 5.0.0-next.162 
    vite: ^5.3.1 => 5.3.1

Severity

annoyance

Additional Information

No response

@jasonlyu123
Copy link
Member

This is intentional. The component is a function in svelte 5 and the constructor signature is kept for compatibility. See sveltejs/svelte#11775 for the reasoning. Is there a specific reason why you don't want to see it or you just find that unexpected?

@shinokada
Copy link
Author

Is it possible to adjust for Svelte 5 since it is going to be out of next version?

@dummdidumm
Copy link
Member

No, this is intentional for backwards compatibility as the linked issue explains. We want to output both so that people can use it both way. This will be removed once Svelte 4 syntax is no longer be usable in a future major version of Svelte.

Does this output cause any issues for you in practise? Or is it just that you're wondering why it's using a deprecated syntax?

@shinokada
Copy link
Author

Thanks. I just wanted to clarify. Since VSCode uses the line stroke, I thought I was doing something wrong.

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

No branches or pull requests

3 participants