fix: turn on nullability in the code base.

This commit is contained in:
Miško Hevery
2017-04-14 14:40:56 -07:00
committed by Tobias Bosch
parent 728c9d0632
commit 5293794316
27 changed files with 67 additions and 70 deletions

View File

@ -89,7 +89,7 @@ export function createPlatform(injector: Injector): PlatformRef {
}
_platform = injector.get(PlatformRef);
const inits = injector.get(PLATFORM_INITIALIZER, null);
if (inits) inits.forEach(init => init());
if (inits) inits.forEach((init: any) => init());
return _platform;
}

View File

@ -121,7 +121,8 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
this._removalsHead = insertBefore;
for (let record = insertBefore; record !== null; record = record._nextRemoved) {
for (let record: KeyValueChangeRecord_<K, V>|null = insertBefore; record !== null;
record = record._nextRemoved) {
if (record === this._mapHead) {
this._mapHead = null;
}
@ -150,8 +151,8 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
* - The return value is the new value for the insertion pointer.
*/
private _insertBeforeOrAppend(
before: KeyValueChangeRecord_<K, V>,
record: KeyValueChangeRecord_<K, V>): KeyValueChangeRecord_<K, V> {
before: KeyValueChangeRecord_<K, V>|null,
record: KeyValueChangeRecord_<K, V>): KeyValueChangeRecord_<K, V>|null {
if (before) {
const prev = before._prev;
record._next = before;
@ -181,7 +182,7 @@ export class DefaultKeyValueDiffer<K, V> implements KeyValueDiffer<K, V>, KeyVal
private _getOrCreateRecordForKey(key: K, value: V): KeyValueChangeRecord_<K, V> {
if (this._records.has(key)) {
const record = this._records.get(key);
const record = this._records.get(key) !;
this._maybeAddToChanges(record, value);
const prev = record._prev;
const next = record._next;

View File

@ -30,7 +30,5 @@ export enum SecurityContext {
* @stable
*/
export abstract class Sanitizer {
abstract sanitize(context: SecurityContext, value: null): null;
abstract sanitize(context: SecurityContext, value: {}|string): string;
abstract sanitize(context: SecurityContext, value: {}|string|null): string|null;
}

View File

@ -273,7 +273,8 @@ function setElementClass(view: ViewData, renderNode: any, name: string, value: b
function setElementStyle(
view: ViewData, binding: BindingDef, renderNode: any, name: string, value: any) {
let renderValue: string|null = view.root.sanitizer.sanitize(SecurityContext.STYLE, value);
let renderValue: string|null =
view.root.sanitizer.sanitize(SecurityContext.STYLE, value as{} | string);
if (renderValue != null) {
renderValue = renderValue.toString();
const unit = binding.suffix;