New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): allow readonly arrays in NgModule imports and exports #48106
base: main
Are you sure you want to change the base?
fix(core): allow readonly arrays in NgModule imports and exports #48106
Conversation
Note to a reviewer: I'm not sure if we can make this change in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
reviewed-for: fw-core, public-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
NgModule should support readonly arrays in `@NgModule.imports` and `@NgModule.exports`. Fixes angular#48089
c985860
to
22e317c
Compare
@@ -136,7 +136,7 @@ export interface NgModule { | |||
* ``` | |||
* | |||
*/ | |||
imports?: Array<Type<any>|ModuleWithProviders<{}>|any[]>; | |||
imports?: Array<Type<any>|ModuleWithProviders<{}>|ReadonlyArray<any>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be:
imports?: Array<Type<any>|ModuleWithProviders<{}>|ReadonlyArray<any>>; | |
imports?: Array<Type<any>|ModuleWithProviders<{}>|ReadonlyArray<Type<any>>>; |
in which case I think we can just do:
imports?: Array<Type<any>|ModuleWithProviders<{}>|ReadonlyArray<any>>; | |
imports?: ReadonlyArray<Type<any>|ModuleWithProviders<{}>; |
as all Array
s are implicitly ReadonlyArray
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can Type<any>
represent an array of types? Previously, it was valid to import an array directly, like this:
const myArr = [/*...*/];
import: [myArr]
IMO keeping the type as-is can be more descriptive about what the import
accepts.
@pkozlowski-opensource are you planning to finish this PR anytime in near future? |
Any update on this? |
Based on the following rejections and @pkozlowski-opensource lack of response, it seems the PR will be just forgotten until it's closed due to its age. |
Following this since it is still a problem on production code. |
NgModule should support readonly arrays in
@NgModule.imports
and@NgModule.exports
.Partly fixes #48089 (#48091 is also needed)