Skip to content

Commit 3160d8a

Browse files
Improved some types
1 parent 9c5acf0 commit 3160d8a

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/core/matches.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// @require ./cash.ts
33

4-
function matches ( ele: Ele, selector: string ): boolean {
4+
function matches ( ele: any, selector: string ): boolean {
55

66
const matches = ele && ( ele['matches'] || ele['webkitMatchesSelector'] || ele['mozMatchesSelector'] || ele['msMatchesSelector'] || ele['oMatchesSelector'] );
77

@@ -10,7 +10,7 @@ function matches ( ele: Ele, selector: string ): boolean {
1010
}
1111

1212
interface CashStatic {
13-
matches ( ele: Ele, selector: string ): boolean;
13+
matches ( ele: any, selector: string ): boolean;
1414
}
1515

1616
cash.matches = matches;

src/core/type_checking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ function isWindow ( x: any ): x is Window {
1010
}
1111

1212
function isDocument ( x: any ): x is Document {
13-
return x.nodeType === 9;
13+
return !!x && x.nodeType === 9;
1414
}
1515

1616
function isElement ( x: any ): x is HTMLElement {
17-
return x.nodeType === 1;
17+
return !!x && x.nodeType === 1;
1818
}
1919

2020
function isFunction ( x: any ): x is Function {

src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface CashStatic {
1313
type plainObject = { [index: string]: any };
1414
type falsy = undefined | null | false | 0 | '';
1515

16-
type Ele = Window | Document | HTMLElement | Element | Node | EventTarget;
16+
type Ele = Window | Document | HTMLElement | Element | Node;
1717
type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele[] | ArrayLike<Ele> | Cash;
1818
type Comparator = string | Ele | Cash | (( this: Ele, index: number, ele: Ele ) => boolean);
1919
type Context = Document | HTMLElement | Element;

src/events/on.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function on ( this: Cash, eventFullName: string | plainObject, selector?: string
5252

5353
if ( event.namespace && !hasNamespaces ( namespaces, event.namespace.split ( eventsNamespacesSeparator ) ) ) return;
5454

55-
let thisArg = ele;
55+
let thisArg: EventTarget = ele;
5656

5757
if ( selector ) {
5858

0 commit comments

Comments
 (0)