Home / Function/ ExpressionStatement() — svelte Function Reference

ExpressionStatement() — svelte Function Reference

Architecture documentation for the ExpressionStatement() function in ExpressionStatement.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  d7b99393_7b13_9251_3e40_42dacf82184e["ExpressionStatement()"]
  dbb15ae0_a432_16e3_1429_24ffed462356["ExpressionStatement.js"]
  d7b99393_7b13_9251_3e40_42dacf82184e -->|defined in| dbb15ae0_a432_16e3_1429_24ffed462356
  0d904c38_bd28_9a6b_c31f_2f085bc973e8["legacy_component_creation()"]
  d7b99393_7b13_9251_3e40_42dacf82184e -->|calls| 0d904c38_bd28_9a6b_c31f_2f085bc973e8
  style d7b99393_7b13_9251_3e40_42dacf82184e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js lines 9–38

export function ExpressionStatement(node, context) {
	// warn on `new Component({ target: ... })` if imported from a `.svelte` file
	if (
		node.expression.type === 'NewExpression' &&
		node.expression.callee.type === 'Identifier' &&
		node.expression.arguments.length === 1 &&
		node.expression.arguments[0].type === 'ObjectExpression' &&
		node.expression.arguments[0].properties.some(
			(p) => p.type === 'Property' && p.key.type === 'Identifier' && p.key.name === 'target'
		)
	) {
		const binding = context.state.scope.get(node.expression.callee.name);

		if (binding?.kind === 'normal' && binding.declaration_kind === 'import') {
			const declaration = /** @type {ImportDeclaration} */ (binding.initial);

			// Theoretically someone could import a class from a `.svelte.js` module, but that's too rare to worry about
			if (
				/** @type {string} */ (declaration.source.value).endsWith('.svelte') &&
				declaration.specifiers.find(
					(s) => s.local.name === binding.node.name && s.type === 'ImportDefaultSpecifier'
				)
			) {
				w.legacy_component_creation(node.expression);
			}
		}
	}

	context.next();
}

Domain

Subdomains

Frequently Asked Questions

What does ExpressionStatement() do?
ExpressionStatement() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js.
Where is ExpressionStatement() defined?
ExpressionStatement() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js at line 9.
What does ExpressionStatement() call?
ExpressionStatement() calls 1 function(s): legacy_component_creation.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free