fix(platform-browser): Update types for TypeScript nullability support
Closes #15898
This commit is contained in:

committed by
Tobias Bosch

parent
01d93f3af8
commit
728c9d0632
@ -44,7 +44,8 @@ export class ClientMessageBrokerFactory_ extends ClientMessageBrokerFactory {
|
||||
* @experimental WebWorker support in Angular is experimental.
|
||||
*/
|
||||
export abstract class ClientMessageBroker {
|
||||
abstract runOnService(args: UiArguments, returnType: Type<any>|SerializerTypes): Promise<any>;
|
||||
abstract runOnService(args: UiArguments, returnType: Type<any>|SerializerTypes|null):
|
||||
Promise<any>|null;
|
||||
}
|
||||
|
||||
interface PromiseCompleter {
|
||||
@ -78,7 +79,7 @@ export class ClientMessageBroker_ extends ClientMessageBroker {
|
||||
return id;
|
||||
}
|
||||
|
||||
runOnService(args: UiArguments, returnType: Type<any>|SerializerTypes): Promise<any> {
|
||||
runOnService(args: UiArguments, returnType: Type<any>|SerializerTypes): Promise<any>|null {
|
||||
const fnArgs: any[] = [];
|
||||
if (args.args) {
|
||||
args.args.forEach(argument => {
|
||||
@ -90,10 +91,10 @@ export class ClientMessageBroker_ extends ClientMessageBroker {
|
||||
});
|
||||
}
|
||||
|
||||
let promise: Promise<any>;
|
||||
let id: string = null;
|
||||
let promise: Promise<any>|null;
|
||||
let id: string|null = null;
|
||||
if (returnType != null) {
|
||||
let completer: PromiseCompleter;
|
||||
let completer: PromiseCompleter = undefined !;
|
||||
promise = new Promise((resolve, reject) => { completer = {resolve, reject}; });
|
||||
id = this._generateMessageId(args.method);
|
||||
this._pending.set(id, completer);
|
||||
@ -127,12 +128,12 @@ export class ClientMessageBroker_ extends ClientMessageBroker {
|
||||
|
||||
private _handleMessage(message: ResponseMessageData): void {
|
||||
if (message.type === 'result' || message.type === 'error') {
|
||||
const id = message.id;
|
||||
const id = message.id !;
|
||||
if (this._pending.has(id)) {
|
||||
if (message.type === 'result') {
|
||||
this._pending.get(id).resolve(message.value);
|
||||
this._pending.get(id) !.resolve(message.value);
|
||||
} else {
|
||||
this._pending.get(id).reject(message.value);
|
||||
this._pending.get(id) !.reject(message.value);
|
||||
}
|
||||
this._pending.delete(id);
|
||||
}
|
||||
|
@ -34,5 +34,7 @@ export class RenderStore {
|
||||
return this._lookupById.has(id) ? this._lookupById.get(id) : null;
|
||||
}
|
||||
|
||||
serialize(obj: any): number { return obj == null ? null : this._lookupByObject.get(obj); }
|
||||
serialize(obj: any): number|null|undefined {
|
||||
return obj == null ? null : this._lookupByObject.get(obj);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ export const PRIMITIVE = SerializerTypes.PRIMITIVE;
|
||||
export class LocationType {
|
||||
constructor(
|
||||
public href: string, public protocol: string, public host: string, public hostname: string,
|
||||
public port: string, public pathname: string, public search: string, public hash: string,
|
||||
public port: string, public pathname: string|null, public search: string, public hash: string,
|
||||
public origin: string) {}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ export class Serializer {
|
||||
return obj.map(v => this.serialize(v, type));
|
||||
}
|
||||
if (type === SerializerTypes.RENDER_STORE_OBJECT) {
|
||||
return this._renderStore.serialize(obj);
|
||||
return this._renderStore.serialize(obj) !;
|
||||
}
|
||||
if (type === RenderComponentType) {
|
||||
return this._serializeRenderComponentType(obj);
|
||||
|
@ -47,7 +47,7 @@ export class ServiceMessageBrokerFactory_ extends ServiceMessageBrokerFactory {
|
||||
*/
|
||||
export abstract class ServiceMessageBroker {
|
||||
abstract registerMethod(
|
||||
methodName: string, signature: Array<Type<any>|SerializerTypes>, method: Function,
|
||||
methodName: string, signature: Array<Type<any>|SerializerTypes>|null, method: Function,
|
||||
returnType?: Type<any>|SerializerTypes): void;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ export class ServiceMessageBroker_ extends ServiceMessageBroker {
|
||||
|
||||
private _handleMessage(message: ReceivedMessage): void {
|
||||
if (this._methods.has(message.method)) {
|
||||
this._methods.get(message.method)(message);
|
||||
this._methods.get(message.method) !(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user