Skip to content

Commit

Permalink
update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 15, 2024
1 parent 28e05ed commit b423b5c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
18 changes: 6 additions & 12 deletions documentation/docs/98-reference/.generated/compile-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ Expected whitespace
Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case
```

### inspect_trace_invalid_placement

```
`$inspect.trace(...)` must be the first statement of a function body
```

### invalid_arguments_usage

```
Expand Down Expand Up @@ -970,18 +976,6 @@ A `<textarea>` can have either a value attribute or (equivalently) child content
`<title>` can only contain text and {tags}
```

### trace_rune_invalid_argument

```
`$inspect.trace` requires a string argument for the trace name
```

### trace_rune_invalid_location

```
`$inspect.trace(...)` must be the first statement of a function body
```

### transition_conflict

```
Expand Down
12 changes: 4 additions & 8 deletions packages/svelte/messages/compile-errors/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@

> Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case
## inspect_trace_invalid_placement

> `$inspect.trace(...)` must be the first statement of a function body
## invalid_arguments_usage

> The arguments keyword cannot be used within the template or at the top level of a component
Expand Down Expand Up @@ -186,14 +190,6 @@ It's possible to export a snippet from a `<script module>` block, but only if it
Using a `$` prefix to refer to the value of a store is only possible inside `.svelte` files, where Svelte can automatically create subscriptions when a component is mounted and unsubscribe when the component is unmounted. Consider migrating to runes instead.

## trace_rune_invalid_argument

> `$inspect.trace` requires a string argument for the trace name
## trace_rune_invalid_location

> `$inspect.trace(...)` must be the first statement of a function body
## typescript_invalid_feature

> TypeScript language features like %feature% are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)
13 changes: 2 additions & 11 deletions packages/svelte/src/compiler/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,22 +469,13 @@ export function store_invalid_subscription_module(node) {
e(node, "store_invalid_subscription_module", `Cannot reference store value outside a \`.svelte\` file\nhttps://svelte.dev/e/store_invalid_subscription_module`);
}

/**
* `$inspect.trace` requires a string argument for the trace name
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function trace_rune_invalid_argument(node) {
e(node, "trace_rune_invalid_argument", `\`$inspect.trace\` requires a string argument for the trace name\nhttps://svelte.dev/e/trace_rune_invalid_argument`);
}

/**
* `$inspect.trace(...)` must be the first statement of a function body
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function trace_rune_invalid_location(node) {
e(node, "trace_rune_invalid_location", `\`$inspect.trace(...)\` must be the first statement of a function body\nhttps://svelte.dev/e/trace_rune_invalid_location`);
export function inspect_trace_invalid_placement(node) {
e(node, "inspect_trace_invalid_placement", `\`$inspect.trace(...)\` must be the first statement of a function body\nhttps://svelte.dev/e/inspect_trace_invalid_placement`);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function CallExpression(node, context) {
) ||
grand_parent.body[0] !== parent
) {
e.trace_rune_invalid_location(node);
e.inspect_trace_invalid_placement(node);
}

if (dev) {
Expand Down

0 comments on commit b423b5c

Please sign in to comment.