fix(core): distinguish injection tokens based on their value type#47461
fix(core): distinguish injection tokens based on their value type#47461crisbeto wants to merge 1 commit into
Conversation
a1b96f5 to
8cd5e04
Compare
|
This passed a TGP so I'm assuming that it won't be particularly breaking externally either. I'll bump it up to |
There was a problem hiding this comment.
I haven't tried packaging and testing it, but I assumed it would be fine since we have other places with these sorts of branding properties.
There was a problem hiding this comment.
+1 to test this after packaging and/or add a check in one of the apps within integration folder (where apps work with built packages).
There was a problem hiding this comment.
I ended up making it a public __brand__ property. We appear to be using this pattern in a few other places.
There was a problem hiding this comment.
A private field is not stripped from .d.ts files, Paul's playground link shows the following .d.ts output:
export declare class X<T> {
private p;
}so it should be possible to make it private, but not @internal. I like the __brand__ naming though.
There was a problem hiding this comment.
yes, the field is not stripped- but the type.
e8a832c to
4cfaeb9
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
jessicajaniuk
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
|
@crisbeto any chance for it to land in v16? |
|
Likely not. I haven't had the time to migrate the internal codebase to avoid the breakages. |
thePunderWoman
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
4cfaeb9 to
911147a
Compare
d513b9f to
875b4ad
Compare
…` token cleanup related to angular/angular/pull/47461
Currently the generic type of `InjectionToken` isn't used anywhere which means that the compiler won't flag the following as an error:
```
const foo = new InjectionToken<number>('foo');
const bar: InjectionToken<string> = foo; // Should be an error, but it's not.
```
These changes add a private property to allow the compiler to distinguish between the two.
Fixes angular#46815.
875b4ad to
3baae5c
Compare
* refactor(material/sidenav): set generic for the `MAT_DRAWER_CONTAINER` token cleanup related to angular/angular/pull/47461 * refactor(material/chips): set generic for the `MAT_CHIP` token cleanup related to angular/angular/pull/47461 * refactor(material/slider): set generic for the `MAT_SLIDER` token cleanup related to angular/angular/pull/47461 * fixup! refactor(material/chips): set generic for the `MAT_CHIP` token * refactor(cdk/drag-drop): set generic for the `CDK_DROP_LIST_GROUP` token cleanup related to angular/angular/pull/47461
* refactor(material/sidenav): set generic for the `MAT_DRAWER_CONTAINER` token cleanup related to angular/angular/pull/47461 * refactor(material/chips): set generic for the `MAT_CHIP` token cleanup related to angular/angular/pull/47461 * refactor(material/slider): set generic for the `MAT_SLIDER` token cleanup related to angular/angular/pull/47461 * fixup! refactor(material/chips): set generic for the `MAT_CHIP` token * refactor(cdk/drag-drop): set generic for the `CDK_DROP_LIST_GROUP` token cleanup related to angular/angular/pull/47461 (cherry picked from commit 8d5a896)
|
This draft PR is being closed because it has been stale for 28 days and has seen no activity from you. If you'd like to see this change land, you can re-open this PR. Thank you for being an Angular contributor! |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently the generic type of
InjectionTokenisn't used anywhere which means that the compiler won't flag the following as an error:These changes add a private property to allow the compiler to distinguish between the two.
Fixes #46815.