native-document 1.0.62 → 1.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -243,7 +243,7 @@ NDElement.prototype.with = function(methods) {
243
243
  this.$localExtensions.set(name, method);
244
244
  }
245
245
 
246
- this[name] = method.bind(this);
246
+ this[name] = method;
247
247
  }
248
248
 
249
249
  return this;
@@ -6,6 +6,12 @@ interface MethodsObject {
6
6
  [methodName: string]: (this: NDElement, ...args: any[]) => any;
7
7
  }
8
8
 
9
+ export type ExtractMethods<T extends MethodsObject> = {
10
+ [K in keyof T]: T[K] extends (this: NDElement, ...args: infer Args) => infer R
11
+ ? (...args: Args) => R
12
+ : never;
13
+ };
14
+
9
15
  export interface NDElement {
10
16
  readonly __$isNDElement: true;
11
17
  readonly $element: HTMLElement;
@@ -14,8 +20,11 @@ export interface NDElement {
14
20
 
15
21
  ref(target: any, name: string): this;
16
22
  refSelf(target: any, name: string): this;
17
- with(methods: MethodsObject): this;
23
+ with<T extends MethodsObject>(methods: T): this & ExtractMethods<T>;
18
24
  extend(methods: MethodsObject): NDElement;
25
+ extend<T extends MethodsObject>(
26
+ methods: T
27
+ ): NDElement & { prototype: NDElement & ExtractMethods<T> };
19
28
 
20
29
  unmountChildren(): this;
21
30
  remove(): this;