fix(compiler): correctly type event handler proxy functions
This commit is contained in:
parent
7192fec841
commit
aa9b617c9d
|
@ -7,7 +7,8 @@
|
|||
*/
|
||||
|
||||
import * as common from '@angular/common';
|
||||
import {CUSTOM_ELEMENTS_SCHEMA, Component, Inject, NgModule, OpaqueToken} from '@angular/core';
|
||||
import {CUSTOM_ELEMENTS_SCHEMA, Component, Directive, EventEmitter, Inject, NgModule, OpaqueToken, Output} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
import {wrapInArray} from './funcs';
|
||||
|
||||
|
@ -51,6 +52,28 @@ export class CompUsingPipes {
|
|||
export class CompUsingCustomElements {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'cmp-event',
|
||||
template: `
|
||||
<div (click)="handleDomEventVoid($event)"></div>
|
||||
<div (click)="handleDomEventPreventDefault($event)"></div>
|
||||
<div (dirEvent)="handleDirEvent($event)"></div>
|
||||
`,
|
||||
})
|
||||
export class CompConsumingEvents {
|
||||
handleDomEventVoid(e: any): void {}
|
||||
handleDomEventPreventDefault(e: any): boolean { return false; }
|
||||
handleDirEvent(e: any): void {}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
selector: '[dirEvent]',
|
||||
})
|
||||
export class DirPublishingEvents {
|
||||
@Output('dirEvent')
|
||||
dirEvent: Observable<string> = new EventEmitter();
|
||||
}
|
||||
|
||||
@NgModule({schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: wrapInArray(CompUsingCustomElements)})
|
||||
export class ModuleUsingCustomElements {
|
||||
}
|
||||
|
|
|
@ -15,18 +15,33 @@ import {MultipleComponentsMyComp, NextComp} from './a/multiple_components';
|
|||
import {AnimateCmp} from './animate';
|
||||
import {BasicComp} from './basic';
|
||||
import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from './entry_components';
|
||||
import {CompUsingPipes, CompWithProviders, CompWithReferences, ModuleUsingCustomElements} from './features';
|
||||
import {CompConsumingEvents, CompUsingPipes, CompWithProviders, CompWithReferences, DirPublishingEvents, ModuleUsingCustomElements} from './features';
|
||||
import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, SomePipeInRootModule, SomeService, someLibModuleWithProviders} from './module_fixtures';
|
||||
import {CompWithNgContent, ProjectingComp} from './projection';
|
||||
import {CompForChildQuery, CompWithChildQuery, CompWithDirectiveChild, DirectiveForQuery} from './queries';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
SomeDirectiveInRootModule, SomePipeInRootModule, AnimateCmp, BasicComp, CompForChildQuery,
|
||||
CompWithEntryComponents, CompWithAnalyzeEntryComponentsProvider, ProjectingComp,
|
||||
CompWithChildQuery, CompWithDirectiveChild, CompWithNgContent,
|
||||
CompUsingRootModuleDirectiveAndPipe, CompWithProviders, CompWithReferences, CompUsingPipes,
|
||||
MultipleComponentsMyComp, DirectiveForQuery, NextComp
|
||||
SomeDirectiveInRootModule,
|
||||
SomePipeInRootModule,
|
||||
AnimateCmp,
|
||||
BasicComp,
|
||||
CompForChildQuery,
|
||||
CompWithEntryComponents,
|
||||
CompWithAnalyzeEntryComponentsProvider,
|
||||
ProjectingComp,
|
||||
CompWithChildQuery,
|
||||
CompWithDirectiveChild,
|
||||
CompWithNgContent,
|
||||
CompUsingRootModuleDirectiveAndPipe,
|
||||
CompWithProviders,
|
||||
CompWithReferences,
|
||||
CompUsingPipes,
|
||||
CompConsumingEvents,
|
||||
DirPublishingEvents,
|
||||
MultipleComponentsMyComp,
|
||||
DirectiveForQuery,
|
||||
NextComp,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule, FormsModule, someLibModuleWithProviders(), ModuleUsingCustomElements,
|
||||
|
|
|
@ -351,7 +351,7 @@ export abstract class AppView<T> {
|
|||
}
|
||||
}
|
||||
|
||||
eventHandler(cb: Function): Function { return cb; }
|
||||
eventHandler<E, R>(cb: (event?: E) => R): (event?: E) => R { return cb; }
|
||||
|
||||
throwDestroyedError(details: string): void { throw new ViewDestroyedError(details); }
|
||||
}
|
||||
|
@ -434,9 +434,9 @@ export class DebugAppView<T> extends AppView<T> {
|
|||
}
|
||||
}
|
||||
|
||||
eventHandler(cb: Function): Function {
|
||||
eventHandler<E, R>(cb: (event?: E) => R): (event?: E) => R {
|
||||
var superHandler = super.eventHandler(cb);
|
||||
return (event: any) => {
|
||||
return (event?: any) => {
|
||||
this._resetDebug();
|
||||
try {
|
||||
return superHandler(event);
|
||||
|
|
Loading…
Reference in New Issue