Skip to content

Commit 1d96c5e

Browse files
author
Anatoly Ostrovsky
committed
Type improvements
1 parent b511cd0 commit 1d96c5e

File tree

20 files changed

+385
-316
lines changed

20 files changed

+385
-316
lines changed

@types/animations/interface.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export interface AnimationOptions {
100100
tempClasses: string | string[];
101101
/** Optional DOM operation callback executed before animation */
102102
domOperation?: () => void;
103+
$$domOperationFired?: boolean;
104+
$$prepared?: boolean;
105+
preparationClasses?: string;
106+
activeClasses?: string;
103107
}
104108
export interface AnimateJsRunner {
105109
$$willAnimate: true;

@types/animations/shared.d.ts

Lines changed: 100 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
export function assertArg(arg: any, name: any, reason: any): any;
2-
export function packageStyles(options: any): {
3-
to: any;
4-
from: any;
5-
};
6-
export function pendClasses(classes: any, fix: any, isPrefix: any): string;
7-
export function removeFromArray(arr: any, val: any): void;
1+
/**
2+
* @param {ng.AnimationOptions} options
3+
*/
4+
export function packageStyles(options: ng.AnimationOptions):
5+
| {
6+
to: Record<string, string | number>;
7+
from: Record<string, string | number>;
8+
}
9+
| {
10+
to?: undefined;
11+
from?: undefined;
12+
};
13+
/**
14+
* @param {string | string[]} classes
15+
* @param {string} fix
16+
* @param {boolean | undefined} [isPrefix]
17+
*/
18+
export function pendClasses(
19+
classes: string | string[],
20+
fix: string,
21+
isPrefix?: boolean | undefined,
22+
): string;
823
/**
924
*
1025
* @param {NodeList|Node} element
@@ -13,31 +28,36 @@ export function removeFromArray(arr: any, val: any): void;
1328
export function stripCommentsFromElement(
1429
element: NodeList | Node,
1530
): Node[] | Node | undefined;
16-
/**
17-
* @param {NodeList|Node} element
18-
* @returns {Node}
19-
*/
20-
export function extractElementNode(element: NodeList | Node): Node;
2131
export function applyAnimationClassesFactory(): (
22-
element: any,
23-
options: any,
32+
/** @type {HTMLElement} */ element: HTMLElement,
33+
/** @type {ng.AnimationOptions} */ options: ng.AnimationOptions,
2434
) => void;
25-
export function prepareAnimationOptions(options: any): any;
26-
export function applyAnimationStyles(element: any, options: any): void;
35+
/**
36+
* @param {ng.AnimationOptions | undefined} options
37+
*/
38+
export function prepareAnimationOptions(
39+
options: ng.AnimationOptions | undefined,
40+
): import("./interface.ts").AnimationOptions;
41+
/**
42+
* @param {HTMLElement} element
43+
* @param {ng.AnimationOptions | undefined} options
44+
*/
45+
export function applyAnimationStyles(
46+
element: HTMLElement,
47+
options: ng.AnimationOptions | undefined,
48+
): void;
2749
/**
2850
* Applies initial animation styles to a DOM element.
2951
*
3052
* This function sets the element's inline styles using the properties
3153
* defined in `options.from`, then clears the property to prevent reuse.
3254
*
3355
* @param {HTMLElement} element - The target DOM element to apply styles to.
34-
* @param {{ from?: Partial<CSSStyleDeclaration> | null }} options - options containing a `from` object with CSS property–value pairs.
56+
* @param {ng.AnimationOptions} [options] - options containing a `from` object with CSS property–value pairs.
3557
*/
3658
export function applyAnimationFromStyles(
3759
element: HTMLElement,
38-
options: {
39-
from?: Partial<CSSStyleDeclaration> | null;
40-
},
60+
options?: ng.AnimationOptions,
4161
): void;
4262
/**
4363
* Applies final animation styles to a DOM element.
@@ -46,41 +66,77 @@ export function applyAnimationFromStyles(
4666
* defined in `options.to`, then clears the property to prevent reuse.
4767
*
4868
* @param {HTMLElement} element - The target DOM element to apply styles to.
49-
* @param {{ to?: Partial<CSSStyleDeclaration> | null }} options - options containing a `from` object with CSS property–value pairs.
69+
* @param {ng.AnimationOptions} [options] - options containing a `from` object with CSS property–value pairs.
5070
*/
5171
export function applyAnimationToStyles(
5272
element: HTMLElement,
53-
options: {
54-
to?: Partial<CSSStyleDeclaration> | null;
55-
},
73+
options?: ng.AnimationOptions,
5674
): void;
75+
/**
76+
* Merge old and new animation options for an element, computing
77+
* the final addClass and removeClass values.
78+
*
79+
* @param {HTMLElement} element - The DOM element being animated.
80+
* @param {{ options?: ng.AnimationOptions; addClass?: string; removeClass?: string }} oldAnimation
81+
* @param {{ options?: ng.AnimationOptions; addClass?: string; removeClass?: string; preparationClasses?: string }} newAnimation
82+
* @returns {ng.AnimationOptions} - The merged animation options.
83+
*/
5784
export function mergeAnimationDetails(
58-
element: any,
59-
oldAnimation: any,
60-
newAnimation: any,
61-
): any;
62-
export function resolveElementClasses(
63-
existing: any,
64-
toAdd: any,
65-
toRemove: any,
66-
): {
67-
addClass: string;
68-
removeClass: string;
69-
};
85+
element: HTMLElement,
86+
oldAnimation: {
87+
options?: ng.AnimationOptions;
88+
addClass?: string;
89+
removeClass?: string;
90+
},
91+
newAnimation: {
92+
options?: ng.AnimationOptions;
93+
addClass?: string;
94+
removeClass?: string;
95+
preparationClasses?: string;
96+
},
97+
): ng.AnimationOptions;
98+
/**
99+
* @param {HTMLElement} element
100+
* @param {string | null} event
101+
* @param {ng.AnimationOptions} options
102+
*/
70103
export function applyGeneratedPreparationClasses(
71-
element: any,
72-
event: any,
73-
options: any,
104+
element: HTMLElement,
105+
event: string | null,
106+
options: ng.AnimationOptions,
74107
): void;
75-
export function clearGeneratedClasses(element: any, options: any): void;
76-
export function blockKeyframeAnimations(node: any, applyBlock: any): string[];
77-
export function applyInlineStyle(node: any, styleTuple: any): void;
78-
export function concatWithSpace(a: any, b: any): any;
108+
/**
109+
* @param {HTMLElement} element
110+
* @param {ng.AnimationOptions} options
111+
*/
112+
export function clearGeneratedClasses(
113+
element: HTMLElement,
114+
options: ng.AnimationOptions,
115+
): void;
116+
/**
117+
* @param {HTMLElement} node
118+
* @param {boolean} applyBlock
119+
* @returns {string[]}
120+
*/
121+
export function blockKeyframeAnimations(
122+
node: HTMLElement,
123+
applyBlock: boolean,
124+
): string[];
125+
/**
126+
* @param {HTMLElement} node
127+
* @param {any[]} styleTuple
128+
*/
129+
export function applyInlineStyle(node: HTMLElement, styleTuple: any[]): void;
130+
/**
131+
* @param {string} a
132+
* @param {string} b
133+
* @returns {string}
134+
*/
135+
export function concatWithSpace(a: string, b: string): string;
79136
export const ADD_CLASS_SUFFIX: "-add";
80137
export const REMOVE_CLASS_SUFFIX: "-remove";
81138
export const EVENT_CLASS_PREFIX: "ng-";
82139
export const ACTIVE_CLASS_SUFFIX: "-active";
83140
export const PREPARE_CLASS_SUFFIX: "-prepare";
84141
export const NG_ANIMATE_CLASSNAME: "ng-animate";
85142
export const NG_ANIMATE_CHILDREN_DATA: "$$ngAnimateChildren";
86-
export const ngMinErr: (arg0: string, ...arg1: any[]) => Error;

@types/namespace.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ import {
8080
} from "./directive/worker/interface.ts";
8181
import { Provider as TProvideService } from "./interface.ts";
8282
import { Location as TLocationService } from "./services/location/location.js";
83-
import { AnimateService as TAnimateService } from "./animations/interface.ts";
83+
import {
84+
AnimateService as TAnimateService,
85+
AnimationOptions as TAnimationOptions,
86+
} from "./animations/interface.ts";
8487
import {
8588
StorageBackend as TStorageBackend,
8689
StorageType as TStorageType,
@@ -185,6 +188,7 @@ declare global {
185188
type UrlService = TUrlService;
186189
type ViewService = TViewService;
187190
type ViewScrollService = TViewScrollService;
191+
type AnimationOptions = TAnimationOptions;
188192
type ErrorHandlingConfig = TErrorHandlingConfig;
189193
type ListenerFn = TListenerFn;
190194
type Listener = TListener;

@types/shared/dom.d.ts

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ export function kebabToCamel(name: string): string;
1111
*/
1212
export function snakeToCamel(name: string): string;
1313
/**
14-
* Removes expando data from this element. If key is provided, only
15-
* its field is removed. If data is empty, also removes `ExpandoStore`
16-
* from cache.
17-
* @param {Element} element
18-
* @param {string} [name] - key of field to remove
14+
* @param {Element & Record<string, any>} element
15+
* @param {string} [name]
1916
*/
20-
export function removeElementData(element: Element, name?: string): void;
17+
export function removeElementData(
18+
element: Element & Record<string, any>,
19+
name?: string,
20+
): void;
2121
/**
2222
* Stores data associated with an element inside the expando property of the DOM element.
2323
*
2424
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Expando MDN Glossary: Expando}
2525
*
26-
* @param {Element} element
26+
* @param {Element & Record<string, any> } element
2727
* @param {boolean} [createIfNecessary=false]
2828
* @returns {import("../interface.ts").ExpandoStore}
2929
*/
3030
export function getExpando(
31-
element: Element,
31+
element: Element & Record<string, any>,
3232
createIfNecessary?: boolean,
3333
): import("../interface.ts").ExpandoStore;
3434
/**
@@ -38,22 +38,30 @@ export function getExpando(
3838
*/
3939
export function isTextNode(html: string): boolean;
4040
/**
41-
* @param {Element} element
41+
* @param {Element & Record<string, any>} element
42+
* @param {Element & Record<string, any>} element
4243
* @param {boolean} [onlyDescendants]
4344
* @returns {void}
4445
*/
45-
export function dealoc(element: Element, onlyDescendants?: boolean): void;
46+
export function dealoc(
47+
element: Element & Record<string, any>,
48+
onlyDescendants?: boolean,
49+
): void;
4650
/**
4751
* Gets or sets cache data for a given element.
4852
*
4953
* @param {Element} element - The DOM element to get or set data on.
50-
* @param {string|Object} key - The key (as a string) to get/set or an object for mass-setting.
54+
* @param {string|Object.<string, any>} key - The key to get/set or an object for mass-setting.
5155
* @param {*} [value] - The value to set. If not provided, the function acts as a getter.
52-
* @returns {*} - The retrieved data if acting as a getter. Otherwise, returns undefined.
56+
* @returns {*} - The retrieved data if acting as a getter. Otherwise, undefined.
5357
*/
5458
export function getOrSetCacheData(
5559
element: Element,
56-
key: string | any,
60+
key:
61+
| string
62+
| {
63+
[x: string]: any;
64+
},
5765
value?: any,
5866
): any;
5967
/**
@@ -128,10 +136,11 @@ export function getController(
128136
name?: string,
129137
): ng.Scope | undefined;
130138
/**
139+
* Walk up the DOM tree (including Shadow DOM) to get inherited data.
131140
*
132-
* @param {Node} element
133-
* @param {string} name
134-
* @returns
141+
* @param {Node} element - The starting element (or document/document fragment)
142+
* @param {string} name - The data key to look up
143+
* @returns {any} - The found value, or undefined if not found
135144
*/
136145
export function getInheritedData(element: Node, name: string): any;
137146
/**
@@ -149,10 +158,10 @@ export function removeElement(element: Element, keepData?: boolean): void;
149158
export function startingTag(elementOrStr: string | Element | Node): string;
150159
/**
151160
* Return the DOM siblings between the first and last node in the given array.
152-
* @param {Array<Node>} nodes An array-like object
153-
* @returns {*[]|Array<Node>} the inputted object or a JQLite collection containing the nodes
161+
* @param {Node[]} nodes
162+
* @returns {Node[]}
154163
*/
155-
export function getBlockNodes(nodes: Array<Node>): any[] | Array<Node>;
164+
export function getBlockNodes(nodes: Node[]): Node[];
156165
/**
157166
* Gets the name of a boolean attribute if it exists on a given element.
158167
*
@@ -230,6 +239,11 @@ export function animatedomInsert(
230239
* @returns {string} The base href.
231240
*/
232241
export function getBaseHref(): string;
242+
/**
243+
* @param {NodeList|Node} element
244+
* @returns {Node | undefined}
245+
*/
246+
export function extractElementNode(element: NodeList | Node): Node | undefined;
233247
/**
234248
* Expando cache for adding properties to DOM nodes with JavaScript.
235249
* This used to be an Object in JQLite decorator, but swapped out for a Map

docs/static/typedoc/assets/hierarchy.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)