Skip to content

Commit bc9c814

Browse files
cexbrayatthePunderWoman
authored andcommitted
refactor(forms): remove Mutable from signal forms public API (angular#64436)
The `Mutable` type is only used internally in the `addDefaultField` function, so it can be avoided to be publicly exposed. PR Close angular#64436
1 parent 7afc193 commit bc9c814

3 files changed

Lines changed: 4 additions & 19 deletions

File tree

goldens/public-api/forms/signals/index.api.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,6 @@ export class MinValidationError extends _NgValidationError {
353353
readonly min: number;
354354
}
355355

356-
// @public
357-
export type Mutable<T> = {
358-
-readonly [P in keyof T]: T[P];
359-
};
360-
361356
// @public
362357
export const NgValidationError: abstract new () => NgValidationError;
363358

packages/forms/signals/src/api/types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ import type {ValidationError, WithOptionalField, WithoutField} from './validatio
1616
*/
1717
declare const ɵɵTYPE: unique symbol;
1818

19-
/**
20-
* Creates a type based on the given type T, but with all readonly properties made writable.
21-
* @template T The type to create a mutable version of.
22-
*
23-
* @experimental 21.0.0
24-
*/
25-
export type Mutable<T> = {
26-
-readonly [P in keyof T]: T[P];
27-
};
28-
2919
/**
3020
* A type that represents either a single value of type `T` or a readonly array of `T`.
3121
* @template T The type of the value(s).

packages/forms/signals/src/field/validation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {computed, Signal} from '@angular/core';
10-
import type {FieldTree, Mutable, TreeValidationResult, ValidationResult} from '../api/types';
9+
import {computed, Signal, ɵWritable} from '@angular/core';
10+
import type {FieldTree, TreeValidationResult, ValidationResult} from '../api/types';
1111
import type {ValidationError, WithOptionalField} from '../api/validation_errors';
1212
import {isArray} from '../util/type_guards';
1313
import type {FieldNode} from './node';
@@ -371,10 +371,10 @@ export function addDefaultField<E extends ValidationError>(
371371
): ValidationResult<E> {
372372
if (isArray(errors)) {
373373
for (const error of errors) {
374-
(error as Mutable<ValidationError>).field ??= field;
374+
(error as ɵWritable<ValidationError>).field ??= field;
375375
}
376376
} else if (errors) {
377-
(errors as Mutable<ValidationError>).field ??= field;
377+
(errors as ɵWritable<ValidationError>).field ??= field;
378378
}
379379
return errors as ValidationResult<E>;
380380
}

0 commit comments

Comments
 (0)