mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Jessica Janiuk
parent
2c72fe3797
commit
afe529cb2d
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user