add experimental.async option

aaa
Rich Harris 8 months ago
parent b78fed8eb7
commit 46a004eef2

@ -444,6 +444,12 @@ Expected token %token%
Expected whitespace
```
### experimental_async
```
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`
```
### export_undefined
```
@ -501,7 +507,7 @@ The arguments keyword cannot be used within the template or at the top level of
### legacy_await_invalid
```
Cannot use `await` at the top level of a component, or in the template, unless in runes mode
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless in runes mode
```
### legacy_export_invalid

@ -70,6 +70,10 @@ This turned out to be buggy and unpredictable, particularly when working with de
> `$effect()` can only be used as an expression statement
## experimental_async
> Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`
## export_undefined
> `%name%` is not defined
@ -100,7 +104,7 @@ This turned out to be buggy and unpredictable, particularly when working with de
## legacy_await_invalid
> Cannot use `await` at the top level of a component, or in the template, unless in runes mode
> Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless in runes mode
## legacy_export_invalid

@ -168,6 +168,15 @@ export function effect_invalid_placement(node) {
e(node, 'effect_invalid_placement', `\`$effect()\` can only be used as an expression statement\nhttps://svelte.dev/e/effect_invalid_placement`);
}
/**
* Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function experimental_async(node) {
e(node, 'experimental_async', `Cannot use \`await\` in deriveds and template expressions, or at the top level of a component, unless the \`experimental.async\` compiler option is \`true\`\nhttps://svelte.dev/e/experimental_async`);
}
/**
* `%name%` is not defined
* @param {null | number | NodeLike} node
@ -234,12 +243,12 @@ export function invalid_arguments_usage(node) {
}
/**
* Cannot use `await` at the top level of a component, or in the template, unless in runes mode
* Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless in runes mode
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function legacy_await_invalid(node) {
e(node, 'legacy_await_invalid', `Cannot use \`await\` at the top level of a component, or in the template, unless in runes mode\nhttps://svelte.dev/e/legacy_await_invalid`);
e(node, 'legacy_await_invalid', `Cannot use \`await\` in deriveds and template expressions, or at the top level of a component, unless in runes mode\nhttps://svelte.dev/e/legacy_await_invalid`);
}
/**

@ -212,6 +212,11 @@ export interface ModuleCompileOptions {
* Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it.
*/
warningFilter?: (warning: Warning) => boolean;
/** Experimental options */
experimental?: {
/** Allow `await` keyword in deriveds, template expressions, and the top level of components */
async?: boolean;
};
}
// The following two somewhat scary looking types ensure that certain types are required but can be undefined still

@ -41,7 +41,11 @@ const common = {
return input;
}),
warningFilter: fun(() => true)
warningFilter: fun(() => true),
experimental: object({
async: boolean(false)
})
};
export const validate_module_options =

@ -933,6 +933,11 @@ declare module 'svelte/compiler' {
* Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it.
*/
warningFilter?: (warning: Warning) => boolean;
/** Experimental options */
experimental?: {
/** Allow `await` keyword in deriveds, template expressions, and the top level of components */
async?: boolean;
};
}
/**
* - `html` the default, for e.g. `<div>` or `<span>`
@ -2635,6 +2640,11 @@ declare module 'svelte/types/compiler/interfaces' {
* Use this to filter out warnings. Return `true` to keep the warning, `false` to discard it.
*/
warningFilter?: (warning: Warning_1) => boolean;
/** Experimental options */
experimental?: {
/** Allow `await` keyword in deriveds, template expressions, and the top level of components */
async?: boolean;
};
}
/**
* - `html` the default, for e.g. `<div>` or `<span>`

Loading…
Cancel
Save