Skip to content

Commit 2712ab9

Browse files
authored
Merge branch 'main' into fix-ordering
2 parents f26229d + c173140 commit 2712ab9

File tree

32 files changed

+778
-819
lines changed

32 files changed

+778
-819
lines changed

.changeset/quick-pumpkins-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: tweak element_invalid_self_closing_tag to exclude namespace

packages/svelte/src/compiler/phases/1-parse/acorn.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @import { Comment, Program } from 'estree' */
2+
/** @import { Node } from 'acorn' */
13
import * as acorn from 'acorn';
24
import { walk } from 'zimmerframe';
35
import { tsPlugin } from 'acorn-typescript';
@@ -23,7 +25,7 @@ export function parse(source, typescript) {
2325
if (typescript) amend(source, ast);
2426
add_comments(ast);
2527

26-
return /** @type {import('estree').Program} */ (ast);
28+
return /** @type {Program} */ (ast);
2729
}
2830

2931
/**
@@ -57,7 +59,7 @@ export function parse_expression_at(source, typescript, index) {
5759
*/
5860
function get_comment_handlers(source) {
5961
/**
60-
* @typedef {import('estree').Comment & {
62+
* @typedef {Comment & {
6163
* start: number;
6264
* end: number;
6365
* }} CommentWithLocation
@@ -149,7 +151,7 @@ function get_comment_handlers(source) {
149151
/**
150152
* Tidy up some stuff left behind by acorn-typescript
151153
* @param {string} source
152-
* @param {import('acorn').Node} node
154+
* @param {Node} node
153155
*/
154156
function amend(source, node) {
155157
return walk(node, null, {

packages/svelte/src/compiler/phases/1-parse/read/expression.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
/** @import { Expression } from 'estree' */
2+
/** @import { Parser } from '../index.js' */
13
import { parse_expression_at } from '../acorn.js';
24
import { regex_whitespace } from '../../patterns.js';
35
import * as e from '../../../errors.js';
46

57
/**
6-
* @param {import('../index.js').Parser} parser
7-
* @returns {import('estree').Expression}
8+
* @param {Parser} parser
9+
* @returns {Expression}
810
*/
911
export default function read_expression(parser) {
1012
try {
@@ -35,7 +37,7 @@ export default function read_expression(parser) {
3537

3638
parser.index = index;
3739

38-
return /** @type {import('estree').Expression} */ (node);
40+
return /** @type {Expression} */ (node);
3941
} catch (err) {
4042
parser.acorn_error(err);
4143
}

packages/svelte/src/compiler/phases/1-parse/state/element.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/** @import { Parser } from '../index.js' */
1+
/** @import { Expression } from 'estree' */
22
/** @import * as Compiler from '#compiler' */
3+
/** @import { Parser } from '../index.js' */
34
import { is_void } from '../../../../constants.js';
45
import read_expression from '../read/expression.js';
56
import { read_script } from '../read/script.js';
@@ -589,7 +590,7 @@ function read_attribute(parser) {
589590

590591
const first_value = value === true ? undefined : Array.isArray(value) ? value[0] : value;
591592

592-
/** @type {import('estree').Expression | null} */
593+
/** @type {Expression | null} */
593594
let expression = null;
594595

595596
if (first_value) {

packages/svelte/src/compiler/phases/1-parse/state/tag.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/** @import { ArrowFunctionExpression, Expression, Identifier } from 'estree' */
2+
/** @import { AwaitBlock, ConstTag, DebugTag, EachBlock, ExpressionTag, HtmlTag, IfBlock, KeyBlock, RenderTag, SnippetBlock } from '#compiler' */
3+
/** @import { Parser } from '../index.js' */
14
import read_pattern from '../read/context.js';
25
import read_expression from '../read/expression.js';
36
import * as e from '../../../errors.js';
@@ -7,7 +10,7 @@ import { parse_expression_at } from '../acorn.js';
710

811
const regex_whitespace_with_closing_curly_brace = /^\s*}/;
912

10-
/** @param {import('../index.js').Parser} parser */
13+
/** @param {Parser} parser */
1114
export default function tag(parser) {
1215
const start = parser.index;
1316
parser.index += 1;
@@ -29,7 +32,7 @@ export default function tag(parser) {
2932
parser.allow_whitespace();
3033
parser.eat('}', true);
3134

32-
/** @type {ReturnType<typeof parser.append<import('#compiler').ExpressionTag>>} */
35+
/** @type {ReturnType<typeof parser.append<ExpressionTag>>} */
3336
parser.append({
3437
type: 'ExpressionTag',
3538
start,
@@ -42,15 +45,15 @@ export default function tag(parser) {
4245
});
4346
}
4447

45-
/** @param {import('../index.js').Parser} parser */
48+
/** @param {Parser} parser */
4649
function open(parser) {
4750
let start = parser.index - 2;
4851
while (parser.template[start] !== '{') start -= 1;
4952

5053
if (parser.eat('if')) {
5154
parser.require_whitespace();
5255

53-
/** @type {ReturnType<typeof parser.append<import('#compiler').IfBlock>>} */
56+
/** @type {ReturnType<typeof parser.append<IfBlock>>} */
5457
const block = parser.append({
5558
type: 'IfBlock',
5659
elseif: false,
@@ -76,7 +79,7 @@ function open(parser) {
7679
const template = parser.template;
7780
let end = parser.template.length;
7881

79-
/** @type {import('estree').Expression | undefined} */
82+
/** @type {Expression | undefined} */
8083
let expression;
8184

8285
// we have to do this loop because `{#each x as { y = z }}` fails to parse —
@@ -119,7 +122,7 @@ function open(parser) {
119122
expression = walk(expression, null, {
120123
// @ts-expect-error
121124
TSAsExpression(node, context) {
122-
if (node.end === /** @type {import('estree').Expression} */ (expression).end) {
125+
if (node.end === /** @type {Expression} */ (expression).end) {
123126
assertion = node;
124127
end = node.expression.end;
125128
return node.expression;
@@ -171,7 +174,7 @@ function open(parser) {
171174

172175
parser.eat('}', true);
173176

174-
/** @type {ReturnType<typeof parser.append<import('#compiler').EachBlock>>} */
177+
/** @type {ReturnType<typeof parser.append<EachBlock>>} */
175178
const block = parser.append({
176179
type: 'EachBlock',
177180
start,
@@ -195,7 +198,7 @@ function open(parser) {
195198
const expression = read_expression(parser);
196199
parser.allow_whitespace();
197200

198-
/** @type {ReturnType<typeof parser.append<import('#compiler').AwaitBlock>>} */
201+
/** @type {ReturnType<typeof parser.append<AwaitBlock>>} */
199202
const block = parser.append({
200203
type: 'AwaitBlock',
201204
start,
@@ -249,7 +252,7 @@ function open(parser) {
249252

250253
parser.eat('}', true);
251254

252-
/** @type {ReturnType<typeof parser.append<import('#compiler').KeyBlock>>} */
255+
/** @type {ReturnType<typeof parser.append<KeyBlock>>} */
253256
const block = parser.append({
254257
type: 'KeyBlock',
255258
start,
@@ -293,14 +296,14 @@ function open(parser) {
293296
const prelude = parser.template.slice(0, params_start).replace(/\S/g, ' ');
294297
const params = parser.template.slice(params_start, parser.index);
295298

296-
let function_expression = /** @type {import('estree').ArrowFunctionExpression} */ (
299+
let function_expression = /** @type {ArrowFunctionExpression} */ (
297300
parse_expression_at(prelude + `${params} => {}`, parser.ts, params_start)
298301
);
299302

300303
parser.allow_whitespace();
301304
parser.eat('}', true);
302305

303-
/** @type {ReturnType<typeof parser.append<import('#compiler').SnippetBlock>>} */
306+
/** @type {ReturnType<typeof parser.append<SnippetBlock>>} */
304307
const block = parser.append({
305308
type: 'SnippetBlock',
306309
start,
@@ -323,7 +326,7 @@ function open(parser) {
323326
e.expected_block_type(parser.index);
324327
}
325328

326-
/** @param {import('../index.js').Parser} parser */
329+
/** @param {Parser} parser */
327330
function next(parser) {
328331
const start = parser.index - 1;
329332

@@ -352,7 +355,7 @@ function next(parser) {
352355
let elseif_start = start - 1;
353356
while (parser.template[elseif_start] !== '{') elseif_start -= 1;
354357

355-
/** @type {ReturnType<typeof parser.append<import('#compiler').IfBlock>>} */
358+
/** @type {ReturnType<typeof parser.append<IfBlock>>} */
356359
const child = parser.append({
357360
start: elseif_start,
358361
end: -1,
@@ -434,7 +437,7 @@ function next(parser) {
434437
e.block_invalid_continuation_placement(start);
435438
}
436439

437-
/** @param {import('../index.js').Parser} parser */
440+
/** @param {Parser} parser */
438441
function close(parser) {
439442
const start = parser.index - 1;
440443

@@ -448,7 +451,7 @@ function close(parser) {
448451
while (block.elseif) {
449452
block.end = parser.index;
450453
parser.stack.pop();
451-
block = /** @type {import('#compiler').IfBlock} */ (parser.current());
454+
block = /** @type {IfBlock} */ (parser.current());
452455
}
453456
block.end = parser.index;
454457
parser.pop();
@@ -482,7 +485,7 @@ function close(parser) {
482485
parser.pop();
483486
}
484487

485-
/** @param {import('../index.js').Parser} parser */
488+
/** @param {Parser} parser */
486489
function special(parser) {
487490
let start = parser.index;
488491
while (parser.template[start] !== '{') start -= 1;
@@ -496,7 +499,7 @@ function special(parser) {
496499
parser.allow_whitespace();
497500
parser.eat('}', true);
498501

499-
/** @type {ReturnType<typeof parser.append<import('#compiler').HtmlTag>>} */
502+
/** @type {ReturnType<typeof parser.append<HtmlTag>>} */
500503
parser.append({
501504
type: 'HtmlTag',
502505
start,
@@ -508,7 +511,7 @@ function special(parser) {
508511
}
509512

510513
if (parser.eat('debug')) {
511-
/** @type {import('estree').Identifier[]} */
514+
/** @type {Identifier[]} */
512515
let identifiers;
513516

514517
// Implies {@debug} which indicates "debug all"
@@ -519,8 +522,8 @@ function special(parser) {
519522

520523
identifiers =
521524
expression.type === 'SequenceExpression'
522-
? /** @type {import('estree').Identifier[]} */ (expression.expressions)
523-
: [/** @type {import('estree').Identifier} */ (expression)];
525+
? /** @type {Identifier[]} */ (expression.expressions)
526+
: [/** @type {Identifier} */ (expression)];
524527

525528
identifiers.forEach(
526529
/** @param {any} node */ (node) => {
@@ -534,7 +537,7 @@ function special(parser) {
534537
parser.eat('}', true);
535538
}
536539

537-
/** @type {ReturnType<typeof parser.append<import('#compiler').DebugTag>>} */
540+
/** @type {ReturnType<typeof parser.append<DebugTag>>} */
538541
parser.append({
539542
type: 'DebugTag',
540543
start,
@@ -567,7 +570,7 @@ function special(parser) {
567570

568571
parser.eat('}', true);
569572

570-
/** @type {ReturnType<typeof parser.append<import('#compiler').ConstTag>>} */
573+
/** @type {ReturnType<typeof parser.append<ConstTag>>} */
571574
parser.append({
572575
type: 'ConstTag',
573576
start,
@@ -598,7 +601,7 @@ function special(parser) {
598601
parser.allow_whitespace();
599602
parser.eat('}', true);
600603

601-
/** @type {ReturnType<typeof parser.append<import('#compiler').RenderTag>>} */
604+
/** @type {ReturnType<typeof parser.append<RenderTag>>} */
602605
parser.append({
603606
type: 'RenderTag',
604607
start,

0 commit comments

Comments
 (0)