fix(core): accept readonly arrays for setClassMetadata decorators

When reflection metadata is emitted via setClassMetadata, passing readonly arrays or const tuples for the decorators parameter causes TypeScript type checking errors because setClassMetadata previously expected decorators to be a mutable any[] or null.

This change updates the setClassMetadata type signature to accept decorators as readonly any[] or null and casts the parameter internally when mutating the class metadata property.

(cherry picked from commit dc65e3656f)
This commit is contained in:
Alex Rickabaugh
2026-07-29 22:40:45 +00:00
committed by Jessica Janiuk
parent 2c72fe3797
commit afe529cb2d
2 changed files with 3 additions and 4 deletions
@@ -403,8 +403,7 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
* A function used by the framework to create standalone injectors.
*/
getStandaloneInjector:
| ((parentInjector: EnvironmentInjector) => EnvironmentInjector | null)
| null;
((parentInjector: EnvironmentInjector) => EnvironmentInjector | null) | null;
/**
* A function used by the framework to create the list of external runtime style URLs.
+2 -2
View File
@@ -86,7 +86,7 @@ export function setClassMetadataAsync(
*/
export function setClassMetadata(
type: any,
decorators: any[] | null,
decorators: readonly any[] | null,
ctorParameters: (() => any[]) | null,
propDecorators: {[field: string]: any} | null,
): void {
@@ -97,7 +97,7 @@ export function setClassMetadata(
if (clazz.hasOwnProperty('decorators') && clazz.decorators !== undefined) {
clazz.decorators.push(...decorators);
} else {
clazz.decorators = decorators;
clazz.decorators = decorators as any[];
}
}
if (ctorParameters !== null) {