Skip to content

Commit 5030922

Browse files
committed
fix: replace modern to modernAst
Add missing `modernAst` in `validate_component_options`.
1 parent 4ea8a5e commit 5030922

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

packages/svelte/src/compiler/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,38 +107,38 @@ function handle_compile_error(error, filename, source) {
107107
/**
108108
* The parse function parses a component, returning only its abstract syntax tree.
109109
*
110-
* The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
111-
* `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
110+
* The `modernAst` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
111+
* `modernAst` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
112112
*
113113
* https://svelte.dev/docs/svelte-compiler#svelte-parse
114114
* @overload
115115
* @param {string} source
116-
* @param {{ filename?: string; modern: true }} options
116+
* @param {{ filename?: string; modernAst: true }} options
117117
* @returns {import('#compiler').Root}
118118
*/
119119

120120
/**
121121
* The parse function parses a component, returning only its abstract syntax tree.
122122
*
123-
* The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
124-
* `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
123+
* The `modernAst` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
124+
* `modernAst` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
125125
*
126126
* https://svelte.dev/docs/svelte-compiler#svelte-parse
127127
* @overload
128128
* @param {string} source
129-
* @param {{ filename?: string; modern?: false }} [options]
129+
* @param {{ filename?: string; modernAst?: false }} [options]
130130
* @returns {import('./types/legacy-nodes.js').LegacyRoot}
131131
*/
132132

133133
/**
134134
* The parse function parses a component, returning only its abstract syntax tree.
135135
*
136-
* The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
137-
* `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
136+
* The `modernAst` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
137+
* `modernAst` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
138138
*
139139
* https://svelte.dev/docs/svelte-compiler#svelte-parse
140140
* @param {string} source
141-
* @param {{ filename?: string; modern?: boolean }} [options]
141+
* @param {{ filename?: string; modernAst?: boolean }} [options]
142142
* @returns {import('#compiler').Root | import('./types/legacy-nodes.js').LegacyRoot}
143143
*/
144144
export function parse(source, options = {}) {
@@ -154,7 +154,7 @@ export function parse(source, options = {}) {
154154
throw e;
155155
}
156156

157-
return to_public_ast(source, ast, options.modern);
157+
return to_public_ast(source, ast, options.modernAst);
158158
}
159159

160160
/**

packages/svelte/src/compiler/validate-options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export const validate_component_options =
8383

8484
namespace: list(['html', 'svg', 'foreign']),
8585

86+
modernAst: boolean(false),
87+
8688
outputFilename: string(undefined),
8789

8890
preserveComments: boolean(false),

packages/svelte/tests/parser-modern/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { test, run } = suite<ParserTest>(async (config, cwd) => {
1515
const actual = JSON.parse(
1616
JSON.stringify(
1717
parse(input, {
18-
modern: true
18+
modernAst: true
1919
})
2020
)
2121
);

packages/svelte/types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,26 +504,26 @@ declare module 'svelte/compiler' {
504504
/**
505505
* The parse function parses a component, returning only its abstract syntax tree.
506506
*
507-
* The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
508-
* `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
507+
* The `modernAst` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
508+
* `modernAst` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
509509
*
510510
* https://svelte.dev/docs/svelte-compiler#svelte-parse
511511
* */
512512
export function parse(source: string, options: {
513513
filename?: string;
514-
modern: true;
514+
modernAst: true;
515515
}): Root;
516516
/**
517517
* The parse function parses a component, returning only its abstract syntax tree.
518518
*
519-
* The `modern` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
520-
* `modern` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
519+
* The `modernAst` option (`false` by default in Svelte 5) makes the parser return a modern AST instead of the legacy AST.
520+
* `modernAst` will become `true` by default in Svelte 6, and the option will be removed in Svelte 7.
521521
*
522522
* https://svelte.dev/docs/svelte-compiler#svelte-parse
523523
* */
524524
export function parse(source: string, options?: {
525525
filename?: string | undefined;
526-
modern?: false | undefined;
526+
modernAst?: false | undefined;
527527
} | undefined): LegacyRoot;
528528
/**
529529
* @deprecated Replace this with `import { walk } from 'estree-walker'`

0 commit comments

Comments
 (0)