[ember] addObserver, removeObserver should return functions (#28921)

Fixes https://github.com/typed-ember/ember-cli-typescript/issues/290
This commit is contained in:
Mike North
2018-09-16 15:00:45 -07:00
committed by Ryan Cavanaugh
parent 9a4fd80c8c
commit d9c8fecb5f
2 changed files with 21 additions and 21 deletions
+17 -17
View File
@@ -1734,11 +1734,11 @@ declare module 'ember' {
key: keyof this,
target: Target,
method: ObserverMethod<Target, this>
): void;
): this;
addObserver(
key: keyof this,
method: ObserverMethod<this, this>
): void;
): this;
/**
* Remove an observer you have previously registered on this object. Pass
* the same key, target, and method you passed to `addObserver()` and your
@@ -1748,11 +1748,11 @@ declare module 'ember' {
key: keyof this,
target: Target,
method: ObserverMethod<Target, this>
): any;
): this;
removeObserver(
key: keyof this,
method: ObserverMethod<this, this>
): any;
): this;
/**
* Retrieves the value of a property, or a default value in the case that the
* property returns `undefined`.
@@ -3147,33 +3147,33 @@ declare module 'ember' {
/**
* Specify a method that observes property changes.
*/
function observer(key1: string, func: (target: any, key: string) => void): void;
function observer(
function observer<Fn extends (target: any, key: string) => void>(key1: string, func: Fn): Fn;
function observer<Fn extends (target: any, key: string) => void>(
key1: string,
key2: string,
func: (target: any, key: string) => void
): void;
function observer(
func: Fn
): Fn;
function observer<Fn extends (target: any, key: string) => void>(
key1: string,
key2: string,
key3: string,
func: (target: any, key: string) => void
): void;
function observer(
func: Fn
): Fn;
function observer<Fn extends (target: any, key: string) => void>(
key1: string,
key2: string,
key3: string,
key4: string,
func: (target: any, key: string) => void
): void;
function observer(
func: Fn
): Fn;
function observer<Fn extends (target: any, key: string) => void>(
key1: string,
key2: string,
key3: string,
key4: string,
key5: string,
func: (target: any, key: string) => void
): void;
func: Fn
): Fn;
/**
* Adds an observer on a property.
*/
+4 -4
View File
@@ -69,13 +69,13 @@ class DemoObservable implements Observable {
notifyPropertyChange(keyName: string): this {
throw new Error("Method not implemented.");
}
addObserver<Target>(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void;
addObserver<K extends keyof this>(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): void;
addObserver<Target>(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): any;
addObserver<K extends keyof this>(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): any;
addObserver(key: any, target: any, method?: any) {
throw new Error("Method not implemented.");
}
removeObserver<Target>(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void;
removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): void;
removeObserver<Target>(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): any;
removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): any;
removeObserver(key: any, target: any, method?: any): void {
throw new Error("Method not implemented.");
}