Skip to content

Better ngClass typings #39280

@dev054

Description

@dev054

🐞 bug report

Affected Package

@angular/common.

Is this a regression?

In ng < 9, the type was any so it worked.

Description

set ngClass(value: string|string[]|Set<string>|{[klass: string]: any}) {

Actually we can't pass readonly arrays or readonly sets with strictTemplates enabled, because the current types don't support it.
Another thing that is really trivial is that we can't use right now it with | async, as it could return null | undefined and it's also not supported.

🌍 Your Environment

Angular Version:

Angular CLI: 10.1.6
Node: 13.7.0
OS: darwin x64

Angular: 10.1.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.6
@angular-devkit/build-angular   0.1001.6
@angular-devkit/core            10.1.6
@angular-devkit/schematics      10.1.6
@angular/cdk                    10.2.4
@angular/cli                    10.1.6
@schematics/angular             10.1.6
@schematics/update              0.1001.6
rxjs                            6.6.3
typescript                      4.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: commonIssues related to APIs in the @angular/common packagecross-cutting: types

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions