fix: migrate `$$Props` without creating non existent props (#13484)

pull/13485/head
Paolo Ricciuti 3 months ago committed by GitHub
parent b665425e5d
commit 344808a719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: migrate `$$Props` without creating non existent props

@ -150,6 +150,7 @@ export function migrate(source) {
props = `...${state.names.props}`;
} else {
props = state.props
.filter((prop) => !prop.type_only)
.map((prop) => {
let prop_str =
prop.local === prop.exported ? prop.local : `${prop.exported}: ${prop.local}`;
@ -282,7 +283,7 @@ export function migrate(source) {
* str: MagicString;
* analysis: ComponentAnalysis;
* indent: string;
* props: Array<{ local: string; exported: string; init: string; bindable: boolean; slot_name?: string; optional: boolean; type: string; comment?: string }>;
* props: Array<{ local: string; exported: string; init: string; bindable: boolean; slot_name?: string; optional: boolean; type: string; comment?: string, type_only?: boolean }>;
* props_insertion_point: number;
* has_props_rune: boolean;
* end: number;
@ -419,6 +420,7 @@ const instance_script = {
: '';
prop.bindable = binding.updated;
prop.exported = binding.prop_alias || name;
prop.type_only = false;
} else {
state.props.push({
local: name,
@ -989,7 +991,8 @@ function handle_identifier(node, state, path) {
bindable: false,
optional: member.optional,
type,
comment
comment,
type_only: true
});
}
}

@ -3,6 +3,8 @@
/** foo */
foo: string;
bar: boolean;
/** should not create a prop */
type_only: boolean;
}
export let foo: $$Props['foo'];

@ -5,6 +5,8 @@
/** foo */
foo: string;
bar: boolean;
/** should not create a prop */
type_only: boolean;
}
let { foo = $bindable(), bar = true }: Props = $props();

Loading…
Cancel
Save