-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix type assertion #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,11 @@ | |
* @typedef {null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>} Test | ||
*/ | ||
|
||
/** | ||
* @template {Element} T | ||
* @typedef {null|undefined|T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>} PredicateTest | ||
*/ | ||
|
||
/** | ||
* Check if an element passes a test | ||
* | ||
|
@@ -22,7 +27,7 @@ | |
* | ||
* @template {Element} X | ||
* @callback TestFunctionPredicate | ||
* @param {X} element | ||
* @param {Element} element | ||
* @param {number|null|undefined} [index] | ||
* @param {Parent|null|undefined} [parent] | ||
* @returns {element is X} | ||
|
@@ -56,8 +61,9 @@ export const isElement = | |
* When a `parent` node is known the `index` of node should also be given. | ||
* | ||
* @type {( | ||
* (<T extends Element>(node: unknown, test: T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>, index?: number, parent?: Parent, context?: unknown) => node is T) & | ||
* ((node?: unknown, test?: Test, index?: number, parent?: Parent, context?: unknown) => boolean) | ||
* (() => false) & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think we should remove this in typings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the benefit in removing it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
TypeScript should be stricter than codes, the benefit is that
Personally, I won't say updating better practice types as breaking change. |
||
* (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) & | ||
* ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean) | ||
wooorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* )} | ||
*/ | ||
( | ||
|
Uh oh!
There was an error while loading. Please reload this page.