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:
Andrea Canciani
2020-03-27 11:44:00 +01:00
committed by Alex Rickabaugh
parent 7b2aac97df
commit 3b919ef10f
4 changed files with 11 additions and 5 deletions

View File

@ -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();
});
});
});

View File

@ -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();
});
});
});