fix(core): Update types for TypeScript nullability support (#15472)

This commit is contained in:
Miško Hevery
2017-03-29 09:34:45 -07:00
committed by Victor Berchet
parent 331b9f6425
commit 910c0d9ee7
84 changed files with 1287 additions and 1260 deletions

View File

@ -21,6 +21,6 @@ export interface PlatformReflectionCapabilities {
method(name: string): MethodFn;
importUri(type: Type<any>): string;
resourceUri(type: Type<any>): string;
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any;
resolveIdentifier(name: string, moduleUrl: string, members: string[]|null, runtime: any): any;
resolveEnum(enumIdentifier: any, name: string): any;
}

View File

@ -54,7 +54,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return result;
}
private _ownParameters(type: Type<any>, parentCtor: any): any[][] {
private _ownParameters(type: Type<any>, parentCtor: any): any[][]|null {
// If we have no decorators, we only have function.length as metadata.
// In that case, to detect whether a child class declared an own constructor or not,
// we need to look inside of that constructor to check whether it is
@ -115,7 +115,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return parameters || [];
}
private _ownAnnotations(typeOrFunc: Type<any>, parentCtor: any): any[] {
private _ownAnnotations(typeOrFunc: Type<any>, parentCtor: any): any[]|null {
// Prefer the direct API.
if ((<any>typeOrFunc).annotations && (<any>typeOrFunc).annotations !== parentCtor.annotations) {
let annotations = (<any>typeOrFunc).annotations;
@ -134,6 +134,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
if (this._reflect && this._reflect.getOwnMetadata) {
return this._reflect.getOwnMetadata('annotations', typeOrFunc);
}
return null;
}
annotations(typeOrFunc: Type<any>): any[] {
@ -146,7 +147,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
return parentAnnotations.concat(ownAnnotations);
}
private _ownPropMetadata(typeOrFunc: any, parentCtor: any): {[key: string]: any[]} {
private _ownPropMetadata(typeOrFunc: any, parentCtor: any): {[key: string]: any[]}|null {
// Prefer the direct API.
if ((<any>typeOrFunc).propMetadata &&
(<any>typeOrFunc).propMetadata !== parentCtor.propMetadata) {
@ -172,6 +173,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
if (this._reflect && this._reflect.getOwnMetadata) {
return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
}
return null;
}
propMetadata(typeOrFunc: any): {[key: string]: any[]} {

View File

@ -51,7 +51,7 @@ export class Reflector extends ReflectorReader {
resourceUri(type: any): string { return this.reflectionCapabilities.resourceUri(type); }
resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any {
resolveIdentifier(name: string, moduleUrl: string, members: string[]|null, runtime: any): any {
return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
}

View File

@ -14,7 +14,7 @@ export abstract class ReflectorReader {
abstract parameters(typeOrFunc: /*Type*/ any): any[][];
abstract annotations(typeOrFunc: /*Type*/ any): any[];
abstract propMetadata(typeOrFunc: /*Type*/ any): {[key: string]: any[]};
abstract importUri(typeOrFunc: /*Type*/ any): string;
abstract importUri(typeOrFunc: /*Type*/ any): string|null;
abstract resourceUri(typeOrFunc: /*Type*/ any): string;
abstract resolveIdentifier(name: string, moduleUrl: string, members: string[], runtime: any): any;
abstract resolveEnum(identifier: any, name: string): any;