-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: warn when using rest or identifier in custom elements without props option #16003
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'svelte': patch | ||
| --- | ||
|
|
||
| fix: warn when using rest or identifier in custom elements without props option |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../svelte/tests/validator/samples/custom-element-props-identifier-props-option/input.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <svelte:options customElement={{ | ||
| props: {} | ||
| }} /> | ||
|
|
||
| <script> | ||
| let props = $props(); | ||
| </script> |
14 changes: 14 additions & 0 deletions
14
...svelte/tests/validator/samples/custom-element-props-identifier-props-option/warnings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } | ||
| ] |
5 changes: 5 additions & 0 deletions
5
packages/svelte/tests/validator/samples/custom-element-props-identifier-rest/input.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <svelte:options customElement={{}} /> | ||
|
|
||
| <script> | ||
| let { ...props } = $props(); | ||
| </script> |
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/validator/samples/custom-element-props-identifier-rest/warnings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 an identifier or a rest element as the declarator for `$props` when compiling to custom elements without declaring `props` in the component options means that Svelte can't know which props to expose as properties on the DOM element. Consider explicitly destructure all the props or add the `customElement.props` option.", | ||
| "start": { | ||
| "column": 7, | ||
| "line": 4 | ||
| } | ||
| } | ||
| ] |
5 changes: 5 additions & 0 deletions
5
packages/svelte/tests/validator/samples/custom-element-props-identifier/input.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <svelte:options customElement={{}} /> | ||
|
|
||
| <script> | ||
| let props = $props(); | ||
| </script> |
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/validator/samples/custom-element-props-identifier/warnings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 an identifier or a rest element as the declarator for `$props` when compiling to custom elements without declaring `props` in the component options means that Svelte can't know which props to expose as properties on the DOM element. Consider explicitly destructure all the props or add the `customElement.props` option.", | ||
| "start": { | ||
| "column": 5, | ||
| "line": 4 | ||
| } | ||
| } | ||
| ] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.