function isExternalDeclarationMerging(
			scope,
			variable,
			shadowedVariable,
		) {
			const firstDefinition = shadowedVariable.defs[0];

			if (!firstDefinition || !firstDefinition.parent) {
				return false;
			}

			// Check if the shadowed variable is a type import
			const isTypeImport =
				firstDefinition.parent.type === "ImportDeclaration" &&
				(firstDefinition.parent.importKind === "type" ||
					firstDefinition.parent.specifiers?.some(
						s =>
							s.type === "ImportSpecifier" &&
							s.importKind === "type" &&
							s.local.name === shadowedVariable.name,
					));

			if (!isTypeImport) {
				return false;
			}

			// Check if the current variable is within a module declaration
			const moduleDecl = findSelfOrAncestor(
				variable.identifiers[0]?.parent,
				node => node.type === "TSModuleDeclaration",
			);

			if (!moduleDecl) {
				return false;
			}

			/*
			 * Module declaration merging should only happen within the same module
			 * Check if the module name matches the import source
			 */
			const importSource = firstDefinition.parent.source.value;
			const moduleName =
				moduleDecl.id.type === "Literal"
					? moduleDecl.id.value
					: moduleDecl.id.name;

			return importSource === moduleName;
		}
Check if this is an external module declaration merging with a type import
@param {Scope} scope Current scope
@param {Object} variable Current variable
@param {Object} shadowedVariable Shadowed variable
@returns {boolean} Whether it's an external declaration merging