Skip to content

chore: remove some todos #16515

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 6 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-countries-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: remove some todos
4 changes: 2 additions & 2 deletions packages/svelte/src/compiler/migrate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1707,14 +1707,14 @@ function extract_type_and_comment(declarator, state, path) {
}

// Ensure modifiers are applied in the same order as Svelte 4
const modifier_order = [
const modifier_order = /** @type {const} */ ([
'preventDefault',
'stopPropagation',
'stopImmediatePropagation',
'self',
'trusted',
'once'
];
]);

/**
* @param {AST.RegularElement | AST.SvelteElement | AST.SvelteWindow | AST.SvelteDocument | AST.SvelteBody} element
Expand Down
1 change: 0 additions & 1 deletion packages/svelte/src/compiler/phases/1-parse/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @import { AST } from '#compiler' */
/** @import { Comment } from 'estree' */
// @ts-expect-error acorn type definitions are borked in the release we use
import { isIdentifierStart, isIdentifierChar } from 'acorn';
import fragment from './state/fragment.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export function CallExpression(node, context) {
['debug', 'dir', 'error', 'group', 'groupCollapsed', 'info', 'log', 'trace', 'warn'].includes(
node.callee.property.name
) &&
node.arguments.some((arg) => arg.type !== 'Literal') // TODO more cases?
node.arguments.some(
(arg) => arg.type === 'SpreadElement' || context.state.scope.evaluate(arg).has_unknown
)
) {
return b.call(
node.callee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import * as b from '#compiler/builders';
import { build_event, build_event_handler } from './shared/events.js';

const modifiers = [
const modifiers = /** @type {const} */ ([
'stopPropagation',
'stopImmediatePropagation',
'preventDefault',
'self',
'trusted',
'once'
];
]);

/**
* @param {AST.OnDirective} node
Expand Down
11 changes: 11 additions & 0 deletions packages/svelte/src/compiler/phases/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ class Evaluation {
*/
is_known = true;

/**
* True if the possible values contains `UNKNOWN`
* @readonly
* @type {boolean}
*/
has_unknown = false;

/**
* True if the value is known to not be null/undefined
* @readonly
Expand Down Expand Up @@ -540,6 +547,10 @@ class Evaluation {
if (value == null || value === UNKNOWN) {
this.is_defined = false;
}

if (value === UNKNOWN) {
this.has_unknown = true;
}
}

if (this.values.size > 1 || typeof this.value === 'symbol') {
Expand Down
12 changes: 11 additions & 1 deletion packages/svelte/src/compiler/types/template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,17 @@ export namespace AST {
name: string;
/** The 'y' in `on:x={y}` */
expression: null | Expression;
modifiers: string[]; // TODO specify
modifiers: Array<
| 'capture'
| 'nonpassive'
| 'once'
| 'passive'
| 'preventDefault'
| 'self'
| 'stopImmediatePropagation'
| 'stopPropagation'
| 'trusted'
>;
/** @internal */
metadata: {
expression: ExpressionMetadata;
Expand Down
12 changes: 11 additions & 1 deletion packages/svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,17 @@ declare module 'svelte/compiler' {
name: string;
/** The 'y' in `on:x={y}` */
expression: null | Expression;
modifiers: string[];
modifiers: Array<
| 'capture'
| 'nonpassive'
| 'once'
| 'passive'
| 'preventDefault'
| 'self'
| 'stopImmediatePropagation'
| 'stopPropagation'
| 'trusted'
>;
}

/** A `style:` directive */
Expand Down
Loading