Repository: rollup/rollup
File: src/ast/nodes/shared/JSXElementBase.ts (TypeScript)

Code before:
import type MagicString from 'magic-string';
import type { NormalizedJsxOptions } from '../../../rollup/types';
import { getRenderedJsxChildren } from '../../../utils/jsx';
import type { RenderOptions } from '../../../utils/renderHelpers';
import type { InclusionContext } from '../../ExecutionContext';
import type Variable from '../../variables/Variable';
import JSXEmptyExpression from '../JSXEmptyExpression';
import JSXExpressionContainer from '../JSXExpressionContainer';
import JSXText from '../JSXText';
import type { JSXChild, JsxMode } from './jsxHelpers';
import { getAndIncludeFactoryVariable } from './jsxHelpers';
import type { IncludeChildren } from './Node';
import { doNotDeoptimize, NodeBase } from './Node';

export default class JSXElementBase extends NodeBase {
	children!: JSXChild[];

	protected factoryVariable: Variable | null = null;
	protected factory: string | null = null;
	declare protected jsxMode: JsxMode;

	initialise() {
		super.initialise();
		const { importSource } = (this.jsxMode = this.getRenderingMode());
		if (importSource) {
			this.scope.context.addImportSource(importSource);
		}
	}

	include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
		if (!this.included) this.includeNode(context);
		for (const child of this.children) {
			child.include(context, includeChildrenRecursively);
		}
	}

	includeNode(context: InclusionContext) {
		this.included = true;
		const { factory, importSource, mode } = this.jsxMode;
		if (factory) {
			this.factory = factory;

Review comment (refactor):
PR description says this refactor switches from `declare` to definite assignment (`!`), but this change does the opposite (`children!:` -> `declare children`). Please update the PR description (or the implementation) so it matches what is actually being refactored and why it helps with the Rollup 5 upgrade diff.

Code after:
import type MagicString from 'magic-string';
import type { NormalizedJsxOptions } from '../../../rollup/types';
import { getRenderedJsxChildren } from '../../../utils/jsx';
import type { RenderOptions } from '../../../utils/renderHelpers';
import type { InclusionContext } from '../../ExecutionContext';
import type Variable from '../../variables/Variable';
import JSXEmptyExpression from '../JSXEmptyExpression';
import JSXExpressionContainer from '../JSXExpressionContainer';
import JSXText from '../JSXText';
import type { JSXChild, JsxMode } from './jsxHelpers';
import { getAndIncludeFactoryVariable } from './jsxHelpers';
import type { IncludeChildren } from './Node';
import { doNotDeoptimize, NodeBase } from './Node';

export default class JSXElementBase extends NodeBase {
	declare children: JSXChild[];

	protected factoryVariable: Variable | null = null;
	protected factory: string | null = null;
	declare protected jsxMode: JsxMode;

	initialise() {
		super.initialise();
		const { importSource } = (this.jsxMode = this.getRenderingMode());
		if (importSource) {
			this.scope.context.addImportSource(importSource);
		}
	}

	include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
		if (!this.included) this.includeNode(context);
		for (const child of this.children) {
			child.include(context, includeChildrenRecursively);
		}
	}

	includeNode(context: InclusionContext) {
		this.included = true;
		const { factory, importSource, mode } = this.jsxMode;
		if (factory) {
			this.factory = factory;