Skip to content

Commit c853d6a

Browse files
committed
more
1 parent 00ffea4 commit c853d6a

File tree

1 file changed

+9
-7
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors

1 file changed

+9
-7
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
/** @import { Expression, Node, Pattern, Statement } from 'estree' */
2+
/** @import { Visitors } from '../types' */
13
import is_reference from 'is-reference';
24
import { serialize_get_binding, serialize_set_binding } from '../utils.js';
35
import * as b from '../../../../utils/builders.js';
46

5-
/** @type {import('../types').Visitors} */
7+
/** @type {Visitors} */
68
export const global_visitors = {
79
Identifier(node, { path, state }) {
8-
if (is_reference(node, /** @type {import('estree').Node} */ (path.at(-1)))) {
10+
if (is_reference(node, /** @type {Node} */ (path.at(-1)))) {
911
if (node.name === '$$props') {
1012
return b.id('$$sanitized_props');
1113
}
@@ -74,7 +76,7 @@ export const global_visitors = {
7476
binding?.kind === 'bindable_prop' ||
7577
is_store
7678
) {
77-
/** @type {import('estree').Expression[]} */
79+
/** @type {Expression[]} */
7880
const args = [];
7981

8082
let fn = '$.update';
@@ -105,7 +107,7 @@ export const global_visitors = {
105107
let fn = '$.update';
106108
if (node.prefix) fn += '_pre';
107109

108-
/** @type {import('estree').Expression[]} */
110+
/** @type {Expression[]} */
109111
const args = [argument];
110112
if (node.operator === '--') {
111113
args.push(b.literal(-1));
@@ -116,7 +118,7 @@ export const global_visitors = {
116118
// turn it into an IIFEE assignment expression: i++ -> (() => { const $$value = i; i+=1; return $$value; })
117119
const assignment = b.assignment(
118120
node.operator === '++' ? '+=' : '-=',
119-
/** @type {import('estree').Pattern} */ (argument),
121+
/** @type {Pattern} */ (argument),
120122
b.literal(1)
121123
);
122124
const serialized_assignment = serialize_set_binding(
@@ -125,14 +127,14 @@ export const global_visitors = {
125127
() => assignment,
126128
node.prefix
127129
);
128-
const value = /** @type {import('estree').Expression} */ (visit(argument));
130+
const value = /** @type {Expression} */ (visit(argument));
129131
if (serialized_assignment === assignment) {
130132
// No change to output -> nothing to transform -> we can keep the original update expression
131133
return next();
132134
} else if (context.state.analysis.runes) {
133135
return serialized_assignment;
134136
} else {
135-
/** @type {import('estree').Statement[]} */
137+
/** @type {Statement[]} */
136138
let statements;
137139
if (node.prefix) {
138140
statements = [b.stmt(serialized_assignment), b.return(value)];

0 commit comments

Comments
 (0)