Home / Function/ Identifier() — svelte Function Reference

Identifier() — svelte Function Reference

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

Function javascript Compiler Transformer calls 17 called by 2

Entity Profile

Dependency Diagram

graph TD
  5c01291d_15ff_bab3_2463_d54766affbf6["Identifier()"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449["Identifier.js"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|defined in| dbcd64ee_7333_aa92_9b8e_ed189c6c4449
  78a6ba9a_5003_f569_a638_76e4f1977809["analyze_component()"]
  78a6ba9a_5003_f569_a638_76e4f1977809 -->|calls| 5c01291d_15ff_bab3_2463_d54766affbf6
  aced5321_4478_4f67_ba8c_e122713c1d9f["calculate_blockers()"]
  aced5321_4478_4f67_ba8c_e122713c1d9f -->|calls| 5c01291d_15ff_bab3_2463_d54766affbf6
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 313d2a82_30ea_3161_3aad_0cc2094979aa
  3d603a58_b4e5_f35d_cd7a_cf4d8bbedc45["invalid_arguments_usage()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 3d603a58_b4e5_f35d_cd7a_cf4d8bbedc45
  96840921_f43d_a26b_1d2e_cd28c0fd6d73["is_rune()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 96840921_f43d_a26b_1d2e_cd28c0fd6d73
  627dc2f8_4dbc_5bb1_8f54_cee503e17098["get()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 627dc2f8_4dbc_5bb1_8f54_cee503e17098
  79569a7f_5a21_a694_3839_be405e76af52["rune_invalid_computed_property()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 79569a7f_5a21_a694_3839_be405e76af52
  7940a558_b321_b500_27a6_8930b5b6e3c5["rune_renamed()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 7940a558_b321_b500_27a6_8930b5b6e3c5
  959c496f_f33c_593a_fa4c_c49609087ec1["rune_removed()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 959c496f_f33c_593a_fa4c_c49609087ec1
  53756df7_983a_5ab6_6fba_b73b65058574["rune_invalid_name()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| 53756df7_983a_5ab6_6fba_b73b65058574
  a592039b_2b4c_156b_9303_62b95bb89c4d["rune_missing_parentheses()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| a592039b_2b4c_156b_9303_62b95bb89c4d
  f10026d2_055e_88d6_ace4_e4f662b54259["is_function()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| f10026d2_055e_88d6_ace4_e4f662b54259
  c460607c_df6f_f0bc_cf31_b4c25e6d1506["evaluate()"]
  5c01291d_15ff_bab3_2463_d54766affbf6 -->|calls| c460607c_df6f_f0bc_cf31_b4c25e6d1506
  style 5c01291d_15ff_bab3_2463_d54766affbf6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js lines 16–193

export function Identifier(node, context) {
	let i = context.path.length;
	let parent = /** @type {Expression} */ (context.path[--i]);

	if (!is_reference(node, parent)) {
		return;
	}

	mark_subtree_dynamic(context.path);

	// If we are using arguments outside of a function, then throw an error
	if (
		node.name === 'arguments' &&
		!context.path.some((n) => n.type === 'FunctionDeclaration' || n.type === 'FunctionExpression')
	) {
		e.invalid_arguments_usage(node);
	}

	// `$$slots` exists even in runes mode
	if (node.name === '$$slots') {
		context.state.analysis.uses_slots = true;
	}

	if (context.state.analysis.runes) {
		if (
			is_rune(node.name) &&
			context.state.scope.get(node.name) === null &&
			context.state.scope.get(node.name.slice(1))?.kind !== 'store_sub'
		) {
			/** @type {Expression} */
			let current = node;
			let name = node.name;

			while (parent.type === 'MemberExpression') {
				if (parent.computed) e.rune_invalid_computed_property(parent);
				name += `.${/** @type {Identifier} */ (parent.property).name}`;

				current = parent;
				parent = /** @type {Expression} */ (context.path[--i]);

				if (!is_rune(name)) {
					if (name === '$effect.active') {
						e.rune_renamed(parent, '$effect.active', '$effect.tracking');
					}

					if (name === '$state.frozen') {
						e.rune_renamed(parent, '$state.frozen', '$state.raw');
					}

					if (name === '$state.is') {
						e.rune_removed(parent, '$state.is');
					}

					e.rune_invalid_name(parent, name);
				}
			}

			if (parent.type !== 'CallExpression') {
				e.rune_missing_parentheses(current);
			}
		}
	}

	let binding = context.state.scope.get(node.name);

	if (!context.state.analysis.runes) {
		if (node.name === '$$props') {
			context.state.analysis.uses_props = true;
		}

		if (node.name === '$$restProps') {
			context.state.analysis.uses_rest_props = true;
		}
	}

	if (binding) {
		if (context.state.expression) {
			context.state.expression.dependencies.add(binding);
			context.state.expression.references.add(binding);
			context.state.expression.has_state ||=
				binding.kind !== 'static' &&

Domain

Subdomains

Frequently Asked Questions

What does Identifier() do?
Identifier() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js.
Where is Identifier() defined?
Identifier() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js at line 16.
What does Identifier() call?
Identifier() calls 17 function(s): const_tag_invalid_reference, evaluate, get, get_rune, invalid_arguments_usage, is_component_node, is_function, is_rune, and 9 more.
What calls Identifier()?
Identifier() is called by 2 function(s): analyze_component, calculate_blockers.

Analyze Your Own Codebase

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

Try Supermodel Free