Home / File/ remove_typescript_nodes.js — svelte Source File

remove_typescript_nodes.js — svelte Source File

Architecture documentation for remove_typescript_nodes.js, a javascript file in the svelte codebase. 4 imports, 1 dependents.

File javascript Compiler Transformer 4 imports 1 dependents 24 functions

Entity Profile

Dependency Diagram

graph LR
  0e67864d_62c6_024e_3588_da959afe5b23["remove_typescript_nodes.js"]
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  0e67864d_62c6_024e_3588_da959afe5b23 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  0e67864d_62c6_024e_3588_da959afe5b23 --> a146f6ac_0088_8736_b6ce_318f9f115170
  c49ac9f8_b355_57a2_8d10_b5fd945c6144["zimmerframe"]
  0e67864d_62c6_024e_3588_da959afe5b23 --> c49ac9f8_b355_57a2_8d10_b5fd945c6144
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  0e67864d_62c6_024e_3588_da959afe5b23 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  cc8de3ad_4bae_f883_44db_d90442053943["index.js"]
  cc8de3ad_4bae_f883_44db_d90442053943 --> 0e67864d_62c6_024e_3588_da959afe5b23
  style 0e67864d_62c6_024e_3588_da959afe5b23 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Context, Visitors } from 'zimmerframe' */
/** @import { FunctionExpression, FunctionDeclaration } from 'estree' */
import { walk } from 'zimmerframe';
import * as b from '#compiler/builders';
import * as e from '../../errors.js';

/**
 * @param {FunctionExpression | FunctionDeclaration} node
 * @param {Context<any, any>} context
 */
function remove_this_param(node, context) {
	if (node.params[0]?.type === 'Identifier' && node.params[0].name === 'this') {
		node.params.shift();
	}
	return context.next();
}

/** @type {Visitors<any, null>} */
const visitors = {
	_(node, context) {
		const n = context.next() ?? node;

		// TODO there may come a time when we decide to preserve type annotations.
		// until that day comes, we just delete them so they don't confuse esrap
		delete n.typeAnnotation;
		delete n.typeParameters;
		delete n.typeArguments;
		delete n.returnType;
		delete n.accessibility;
		delete n.readonly;
		delete n.definite;
		delete n.override;
	},
	Decorator(node) {
		e.typescript_invalid_feature(node, 'decorators (related TSC proposal is not stage 4 yet)');
	},
	ImportDeclaration(node) {
		if (node.importKind === 'type') return b.empty;

		if (node.specifiers?.length > 0) {
			const specifiers = node.specifiers.filter((/** @type {any} */ s) => s.importKind !== 'type');
			if (specifiers.length === 0) return b.empty;

			return { ...node, specifiers };
		}

		return node;
	},
	ExportNamedDeclaration(node, context) {
		if (node.exportKind === 'type') return b.empty;

		if (node.declaration) {
			const result = context.next();
			if (result?.declaration?.type === 'EmptyStatement') {
				return b.empty;
			}
			return result;
		}

		if (node.specifiers) {
// ... (121 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does remove_typescript_nodes.js do?
remove_typescript_nodes.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in remove_typescript_nodes.js?
remove_typescript_nodes.js defines 24 function(s): remove_this_param, remove_typescript_nodes, visitors.ClassBody, visitors.ClassDeclaration, visitors.ClassExpression, visitors.Decorator, visitors.ExportAllDeclaration, visitors.ExportDefaultDeclaration, visitors.ExportNamedDeclaration, visitors.ImportDeclaration, and 14 more.
What does remove_typescript_nodes.js depend on?
remove_typescript_nodes.js imports 4 module(s): builders, e, errors.js, zimmerframe.
What files import remove_typescript_nodes.js?
remove_typescript_nodes.js is imported by 1 file(s): index.js.
Where is remove_typescript_nodes.js in the architecture?
remove_typescript_nodes.js is located at packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/1-parse).

Analyze Your Own Codebase

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

Try Supermodel Free