From c39eb1882c3d889eaa3211b8ca674172fe98eb8a Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sun, 16 Mar 2025 15:51:02 -0700 Subject: [PATCH] Revert "feat(observable): enhance event callback type specificity (#10720)" This reverts commit e2f9687e72f8cbb618a22ad5e9a81633a984a0d5. --- packages/core/data/observable/index.ts | 8 ++++---- packages/core/utils/typescript-utils.d.ts | 9 --------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/packages/core/data/observable/index.ts b/packages/core/data/observable/index.ts index 584e622f66..8f75ff67d0 100644 --- a/packages/core/data/observable/index.ts +++ b/packages/core/data/observable/index.ts @@ -1,4 +1,4 @@ -import { Optional, EndsWith } from '../../utils/typescript-utils'; +import { Optional } from '../../utils/typescript-utils'; /** * Base event data. @@ -160,7 +160,7 @@ export class Observable { * `this` context when the callback is called. Falsy values will be not be * bound. */ - public on(eventName: S, callback: (data: EndsWith) => void, thisArg?: any): void { + public on(eventName: string, callback: (data: EventData) => void, thisArg?: any): void { this.addEventListener(eventName, callback, thisArg); } @@ -175,7 +175,7 @@ export class Observable { * `this` context when the callback is called. Falsy values will be not be * bound. */ - public once(eventName: S, callback: (data: EndsWith) => void, thisArg?: any): void { + public once(eventName: string, callback: (data: EventData) => void, thisArg?: any): void { this.addEventListener(eventName, callback, thisArg, true); } @@ -188,7 +188,7 @@ export class Observable { * @param thisArg An optional parameter which, when set, will be used to * refine search of the correct event listener to be removed. */ - public off(eventName: S, callback?: (data: EndsWith) => void, thisArg?: any): void { + public off(eventName: string, callback?: (data: EventData) => void, thisArg?: any): void { this.removeEventListener(eventName, callback, thisArg); } diff --git a/packages/core/utils/typescript-utils.d.ts b/packages/core/utils/typescript-utils.d.ts index 140e46ffd3..2b7de2fd33 100644 --- a/packages/core/utils/typescript-utils.d.ts +++ b/packages/core/utils/typescript-utils.d.ts @@ -4,12 +4,3 @@ * // returns: { eventName: string; object?: Observable } */ export type Optional = Omit & { [P in K]?: T[P] }; - -/** - * Determines if a string type ends with a specified suffix. - * @example type IsChangeEvent = EndsWith<"propertyNameChange", "Change", true, false> - * // returns: true - * @example type IsChangeEvent = EndsWith<"someEvent", "Change", true, false> - * // returns: false - */ -export type EndsWith = T extends `${infer _}${S}` ? PassType : FailType; \ No newline at end of file