Home / Function/ PropertyDefinition() — svelte Function Reference

PropertyDefinition() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  70cf33f6_fb78_c72c_3825_48d021ddd55c["PropertyDefinition()"]
  14a27279_5dd2_0a06_e564_302fb6ffcbc1["PropertyDefinition.js"]
  70cf33f6_fb78_c72c_3825_48d021ddd55c -->|defined in| 14a27279_5dd2_0a06_e564_302fb6ffcbc1
  bed91719_d047_2256_e199_ee875d5f49b9["get_rune()"]
  70cf33f6_fb78_c72c_3825_48d021ddd55c -->|calls| bed91719_d047_2256_e199_ee875d5f49b9
  style 70cf33f6_fb78_c72c_3825_48d021ddd55c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js lines 10–37

export function PropertyDefinition(node, context) {
	if (context.state.analysis.runes && node.value != null && node.value.type === 'CallExpression') {
		const rune = get_rune(node.value, context.state.scope);

		if (rune === '$state' || rune === '$state.raw') {
			return {
				...node,
				value:
					node.value.arguments.length === 0
						? null
						: /** @type {Expression} */ (context.visit(node.value.arguments[0]))
			};
		}

		if (rune === '$derived.by' || rune === '$derived') {
			const fn = /** @type {Expression} */ (context.visit(node.value.arguments[0]));
			return {
				...node,
				value:
					node.value.arguments.length === 0
						? null
						: b.call('$.derived', rune === '$derived' ? b.thunk(fn) : fn)
			};
		}
	}

	context.next();
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does PropertyDefinition() do?
PropertyDefinition() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js.
Where is PropertyDefinition() defined?
PropertyDefinition() is defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js at line 10.
What does PropertyDefinition() call?
PropertyDefinition() calls 1 function(s): get_rune.

Analyze Your Own Codebase

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

Try Supermodel Free