fix(common): Update types for TypeScript nullability support

This commit is contained in:
Miško Hevery
2017-03-24 09:54:02 -07:00
committed by Hans
parent 4c566dbfbb
commit d8b73e4223
29 changed files with 126 additions and 117 deletions

View File

@ -201,14 +201,14 @@ export function main() {
describe('null', () => {
it('should return null when given null', () => {
const pipe = new AsyncPipe(null);
const pipe = new AsyncPipe(null as any);
expect(pipe.transform(null)).toEqual(null);
});
});
describe('other types', () => {
it('should throw when given an invalid object', () => {
const pipe = new AsyncPipe(null);
const pipe = new AsyncPipe(null as any);
expect(() => pipe.transform(<any>'some bogus object')).toThrowError();
});
});

View File

@ -197,7 +197,7 @@ export function main() {
() => expect(pipe.transform('2017-01-20T19:00:00+0000')).toEqual('Jan 20, 2017'));
it('should remove bidi control characters',
() => expect(pipe.transform(date, 'MM/dd/yyyy').length).toEqual(10));
() => expect(pipe.transform(date, 'MM/dd/yyyy') !.length).toEqual(10));
});
});
}

View File

@ -52,7 +52,7 @@ export function main() {
});
it('should use "" if value is undefined', () => {
const val = pipe.transform(void(0), mapping);
const val = pipe.transform(void(0) as any, mapping);
expect(val).toEqual('');
});

View File

@ -51,8 +51,8 @@ export function main() {
describe('transform', () => {
it('should return correct value for numbers', () => {
expect(normalize(pipe.transform(1.23))).toEqual('123%');
expect(normalize(pipe.transform(1.2, '.2'))).toEqual('120.00%');
expect(normalize(pipe.transform(1.23) !)).toEqual('123%');
expect(normalize(pipe.transform(1.2, '.2') !)).toEqual('120.00%');
});
it('should not support other objects',
@ -69,12 +69,12 @@ export function main() {
it('should return correct value for numbers', () => {
// In old Chrome, default formatiing for USD is different
if (browserDetection.isOldChrome) {
expect(normalize(pipe.transform(123))).toEqual('USD123');
expect(normalize(pipe.transform(123) !)).toEqual('USD123');
} else {
expect(normalize(pipe.transform(123))).toEqual('USD123.00');
expect(normalize(pipe.transform(123) !)).toEqual('USD123.00');
}
expect(normalize(pipe.transform(12, 'EUR', false, '.1'))).toEqual('EUR12.0');
expect(normalize(pipe.transform(5.1234, 'USD', false, '.0-3'))).toEqual('USD5.123');
expect(normalize(pipe.transform(12, 'EUR', false, '.1') !)).toEqual('EUR12.0');
expect(normalize(pipe.transform(5.1234, 'USD', false, '.0-3') !)).toEqual('USD5.123');
});
it('should not support other objects',