Skip to content
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

Type for @NgModule.imports is not compatible with recommended standalone group export #55278

Closed
distante opened this issue Apr 10, 2024 · 2 comments

Comments

@distante
Copy link

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

The documentation of Standalone components for library authors states:

As an alternative to publishing a NgModule, library authors might want to export an array of cooperating directives:

export const CAROUSEL_DIRECTIVES = [ImageCarouselComponent, ImageSlideComponent] as const;

Such an array could be imported by applications using NgModules and added to the @NgModule.imports. Please note the presence of the TypeScript’s as const construct: it gives Angular compiler additional information required for proper compilation and is a recommended practice (as it makes the exported array immutable from the TypeScript point of view).

But following that recommendations triggers Typescript warnings in strict mode because a readonly any[] is not compatible with any[]

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.1.3
Node: 20.11.0
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: 17.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, ssr

Package                              Version
--------------------------------------------------------------
@angular-devkit/architect            0.1701.3
@angular-devkit/build-angular        17.1.3
@angular-devkit/core                 17.1.3
@angular-devkit/schematics           17.1.3
@angular/cdk                         17.1.2
@angular/material                    17.1.2
@angular/material-date-fns-adapter   17.1.2
@schematics/angular                  17.1.3
ng-packagr                           17.1.2
rxjs                                 7.8.1
typescript                           5.3.3
webpack                              5.90.1
zone.js                              0.14.3

Anything else?

I think @NgModules.import should not take any[] but Readonly<any[]>.

@JeanMeche
Copy link
Member

Hi, thank you for reporting this issue, It is been discussed in #48089 and there is (was ?) a pending PR for this in #48106.

@JeanMeche JeanMeche closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants