Repository: angular/angular
File: packages/core/src/render3/instructions/control.ts (TypeScript)

Code before:
 * A utility type that extracts the keys from `T` where the value type matches `TCondition`.
 * @template T The object type to extract keys from.
 * @template TCondition The condition to match the value type against.
 */
type KeysWithValueType<T, TCondition> = keyof {
  [K in keyof T as T[K] extends TCondition ? K : never]: never;
};

/**
 * The keys of `ɵFieldState` that can be bound to a control.
 * These are the properties of `ɵFieldState` that are signals or undefined, except for `value`
 * which is not bound directly, but updated indirectly through the `controlValue` binding.
 */
type ControlBindingKeys = Exclude<
  KeysWithValueType<ɵFieldState<unknown>, Signal<any> | undefined>,
  'value'
>;

/**
 * A map of control binding keys to their values.
 * Used to store the last seen values of bound control properties to check for changes.
 */
type ControlBindings = {
  [K in ControlBindingKeys]?: unknown;
} & {
  classes: {[cls: string]: boolean};
};

/**
 * A map of field state properties to control binding name.
 *
 * This excludes `controlValue` whose corresponding control binding name differs between control
 * types.
 *
 * The control binding name can be used for inputs or attributes (since DOM attributes are case
 * insensitive).
 */
const CONTROL_BINDING_NAMES = {
  disabled: 'disabled',
  disabledReasons: 'disabledReasons',
  errors: 'errors',
  invalid: 'invalid',
  max: 'max',
  maxLength: 'maxLength',
  min: 'min',
  minLength: 'minLength',
  name: 'name',
  pattern: 'pattern',
  readonly: 'readonly',
  required: 'required',
  touched: 'touched',

Review comment (suggestion):
Can this not simply be:

```suggestion
  classes: {[cls: string]: boolean};
```

Code after:
}) as 'minLength';

/** A property-renaming safe reference to a property named 'name'. */
const NAME = /* @__PURE__ */ getClosureSafeProperty({name: getClosureSafeProperty}) as 'name';

/** A property-renaming safe reference to a property named 'readonly'. */
const READONLY = /* @__PURE__ */ getClosureSafeProperty({
  readonly: getClosureSafeProperty,
}) as 'readonly';

/** A property-renaming safe reference to a property named 'required'. */
const REQUIRED = /* @__PURE__ */ getClosureSafeProperty({
  required: getClosureSafeProperty,
}) as 'required';

/** A property-renaming safe reference to a property named 'controlValue'. */
const CONTROL_VALUE = /* @__PURE__ */ getClosureSafeProperty({
  controlValue: getClosureSafeProperty,
}) as 'controlValue';

/**
 * A utility type that extracts the keys from `T` where the value type matches `TCondition`.
 * @template T The object type to extract keys from.
 * @template TCondition The condition to match the value type against.
 */
type KeysWithValueType<T, TCondition> = keyof {
  [K in keyof T as T[K] extends TCondition ? K : never]: never;
};

/**
 * The keys of `ɵFieldState` that can be bound to a control.
 * These are the properties of `ɵFieldState` that are signals or undefined, except for `value`
 * which is not bound directly, but updated indirectly through the `controlValue` binding.
 */
type ControlBindingKeys = Exclude<
  KeysWithValueType<ɵFieldState<unknown>, Signal<any> | undefined>,
  'value'
>;

/**
 * A map of control binding keys to their values.
 * Used to store the last seen values of bound control properties to check for changes.
 */
type ControlBindings = {
  [K in ControlBindingKeys]?: unknown;
} & {
  classes: {[className: string]: boolean};
};

/**
 * A map of field state properties to control binding name.