fix(common): correct and simplify typing of I18nPluralPipe (#37447)
I18nPluralPipe can actually accept `null` and `undefined` (which are convenient for composing it with the async pipe), but it is currently typed to only accept `number`. PR Close #37447
This commit is contained in:

committed by
Alex Rickabaugh

parent
7b2aac97df
commit
3b919ef10f
@ -54,12 +54,17 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
});
|
||||
|
||||
it('should use "" if value is undefined', () => {
|
||||
const val = pipe.transform(void (0) as any, mapping);
|
||||
const val = pipe.transform(undefined, mapping);
|
||||
expect(val).toEqual('');
|
||||
});
|
||||
|
||||
it('should use "" if value is null', () => {
|
||||
const val = pipe.transform(null, mapping);
|
||||
expect(val).toEqual('');
|
||||
});
|
||||
|
||||
it('should not support bad arguments', () => {
|
||||
expect(() => pipe.transform(0, <any>'hey')).toThrowError();
|
||||
expect(() => pipe.transform(0, 'hey' as any)).toThrowError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_refle
|
||||
});
|
||||
|
||||
it('should throw on bad arguments', () => {
|
||||
expect(() => pipe.transform('male', <any>'hey')).toThrowError();
|
||||
expect(() => pipe.transform('male', 'hey' as any)).toThrowError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user