mirror of https://github.com/sveltejs/svelte
fix: warn when using rest or identifier in custom elements without props option (#16003)
* fix: warn when using rest or identifier in custom elements without props option * chore: update message * tweak message * update tests --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/16010/head
parent
4e3ff0944d
commit
37488fa65c
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: warn when using rest or identifier in custom elements without props option
|
@ -0,0 +1,7 @@
|
||||
<svelte:options customElement={{
|
||||
props: {}
|
||||
}} />
|
||||
|
||||
<script>
|
||||
let props = $props();
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"code": "options_missing_custom_element",
|
||||
"end": {
|
||||
"column": 2,
|
||||
"line": 3
|
||||
},
|
||||
"message": "The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?",
|
||||
"start": {
|
||||
"column": 16,
|
||||
"line": 1
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,5 @@
|
||||
<svelte:options customElement={{}} />
|
||||
|
||||
<script>
|
||||
let { ...props } = $props();
|
||||
</script>
|
@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"code": "options_missing_custom_element",
|
||||
"end": {
|
||||
"column": 34,
|
||||
"line": 1
|
||||
},
|
||||
"message": "The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?",
|
||||
"start": {
|
||||
"column": 16,
|
||||
"line": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "custom_element_props_identifier",
|
||||
"end": {
|
||||
"column": 15,
|
||||
"line": 4
|
||||
},
|
||||
"message": "Using a rest element or a non-destructured declaration with `$props()` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the `customElement.props` option.",
|
||||
"start": {
|
||||
"column": 7,
|
||||
"line": 4
|
||||
}
|
||||
}
|
||||
]
|
@ -0,0 +1,5 @@
|
||||
<svelte:options customElement={{}} />
|
||||
|
||||
<script>
|
||||
let props = $props();
|
||||
</script>
|
@ -0,0 +1,26 @@
|
||||
[
|
||||
{
|
||||
"code": "options_missing_custom_element",
|
||||
"end": {
|
||||
"column": 34,
|
||||
"line": 1
|
||||
},
|
||||
"message": "The `customElement` option is used when generating a custom element. Did you forget the `customElement: true` compile option?",
|
||||
"start": {
|
||||
"column": 16,
|
||||
"line": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"code": "custom_element_props_identifier",
|
||||
"end": {
|
||||
"column": 10,
|
||||
"line": 4
|
||||
},
|
||||
"message": "Using a rest element or a non-destructured declaration with `$props()` means that Svelte can't infer what properties to expose when creating a custom element. Consider destructuring all the props or explicitly specifying the `customElement.props` option.",
|
||||
"start": {
|
||||
"column": 5,
|
||||
"line": 4
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in new issue