Skip to content

custom_element_props_identifier warnings should not be triggered for internally imported components #16011

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

Open
JetLua opened this issue May 27, 2025 · 4 comments

Comments

@JetLua
Copy link

JetLua commented May 27, 2025

<!-- A.svelte -->
<svelte:options customElement={{
  tag: 'a-btn',
  props: {
    name: {type: 'String'},
  }
}}/>

<script lang="ts">
  import B from './B.svelte'
  const props: {name: string} = $props()

</script>

<B name={props.name}/>
<!-- B.svelte -->

<script lang="ts">
  const props: {name: string} = $props()
</script>

<button>{props.name}</button>

Perhaps a trigger warning shouldn't be issued for file B.svelte.

https://stackblitz.com/edit/vitejs-vite-1tpdpcqa?file=src%2FB.svelte

image

Originally posted by @JetLua in #16003 (comment)

@paoloricciuti
Copy link
Member

Currently the svelte runtime is not using the type information to infer which properties to expose and tbf i don't think we should either as it would be very weird if moving the type to it's own declaration would reintroduce the warning.

So personally I would close this but let's wait what others have to say.

@Ocean-OS
Copy link
Contributor

Ocean-OS commented May 27, 2025

If we were to migrate from acorn-typescript to a parser that analyzes type information across multiple files, we probably could fix that
That might have additional benefits (eg type-informed optimization), but I'm not sure what parsers there are that fit this criteria (other than the typescript package)

@paoloricciuti
Copy link
Member

Find a replacement would be difficult but also cross file compilation would be difficult...not impossible but difficult for sure

@Ocean-OS
Copy link
Contributor

Ocean-OS commented May 27, 2025

Yeah, and at that point it'd seem odd not to implement whole app optimization (#1102) if compilation spanned across multiple files
There's a lot of potential work here, but there's also a lot of potential benefit

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

No branches or pull requests

3 participants