fix(compiler): make sure provider values with name
property don’t break.
Fixes #13394 Closes #13445
This commit is contained in:
parent
a8d237581d
commit
f5f1d5f65c
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import {Component, Injector, OpaqueToken, Pipe, PipeTransform, Provider} from '@angular/core';
|
import {Component, Injector, OpaqueToken, Pipe, PipeTransform, Provider} from '@angular/core';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {beforeEach, describe, it} from '@angular/core/testing/testing_internal';
|
|
||||||
import {expect} from '@angular/platform-browser/testing/matchers';
|
import {expect} from '@angular/platform-browser/testing/matchers';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
@ -139,6 +138,15 @@ function declareTests({useJit}: {useJit: boolean}) {
|
|||||||
expect(injector.get(token1)).toEqual(tokenValue1);
|
expect(injector.get(token1)).toEqual(tokenValue1);
|
||||||
expect(injector.get(token2)).toEqual(tokenValue2);
|
expect(injector.get(token2)).toEqual(tokenValue2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should support providers that have a `name` property with a number value', () => {
|
||||||
|
class TestClass {
|
||||||
|
constructor(public name: number) {}
|
||||||
|
}
|
||||||
|
const data = [new TestClass(1), new TestClass(2)];
|
||||||
|
const injector = createInjector([{provide: 'someToken', useValue: data}]);
|
||||||
|
expect(injector.get('someToken')).toEqual(data);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow logging a previous elements class binding via interpolation', () => {
|
it('should allow logging a previous elements class binding via interpolation', () => {
|
||||||
|
@ -95,11 +95,11 @@ export function stringify(token: any): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (token.overriddenName) {
|
if (token.overriddenName) {
|
||||||
return token.overriddenName;
|
return `${token.overriddenName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.name) {
|
if (token.name) {
|
||||||
return token.name;
|
return `${token.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = token.toString();
|
const res = token.toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user