Skip to content

Commit

Permalink
Check-in type declaration file
Browse files Browse the repository at this point in the history
This is checked-in to source control include manual revisions documenting overloaded functions, due to a suspected upstream bug in TypeScript.

See: microsoft/TypeScript#53350
  • Loading branch information
aduth authored and johnhooks committed Mar 19, 2023
1 parent 9874238 commit f221369
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions es/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @param {Element|string} source Source content
* @param {O} matchers Object of matchers
* @return {{[K in keyof O]: ReturnType<O[K]>}} Matched values, shaped by object
* @param source
* @param matchers
*/
export function parse<T extends unknown, O extends Record<string, MatcherFn<T>>>(
source: Element | string,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"build:es": "babel src/index.ts --out-dir es",
"build:umd": "rollup -c",
"build:types": "tsc -b",
"build": "npm run build:es && npm run build:umd && npm run build:types",
"build": "npm run build:es && npm run build:umd",
"dev": "rollup -c -w",
"lint": "eslint . --ignore-pattern dist --ignore-pattern es",
"unit-test": "NODE_ENV=test mocha --require @babel/register",
Expand Down
22 changes: 22 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const getDocument = (() => {
*/

/**
* Given a markup string or DOM element, creates an object aligning with the
* shape of the matchers object, or the value returned by the matcher.
*
* @template T
* @template {MatcherObj<T>} O
*
Expand All @@ -47,6 +50,9 @@ const getDocument = (() => {
*/

/**
* Given a markup string or DOM element, creates an object aligning with the
* shape of the matchers object, or the value returned by the matcher.
*
* @template {any} T
* @template {MatcherFn<T>} F
*
Expand Down Expand Up @@ -99,6 +105,10 @@ export function parse(source, matchers) {
}

/**
* Generates a function which matches node of type selector, returning an
* attribute by property if the attribute exists. If no selector is passed,
* returns property of the query element.
*
* @template T
*
* @overload
Expand All @@ -107,6 +117,10 @@ export function parse(source, matchers) {
*/

/**
* Generates a function which matches node of type selector, returning an
* attribute by property if the attribute exists. If no selector is passed,
* returns property of the query element.
*
* @template T
*
* @overload
Expand Down Expand Up @@ -144,12 +158,20 @@ export function prop(selector, name) {
}

/**
* Generates a function which matches node of type selector, returning an
* attribute by name if the attribute exists. If no selector is passed,
* returns attribute of the query element.
*
* @overload
* @param {string} name Attribute name
* @return {MatcherFn<string>} Matcher function returning the attribute value
*/

/**
* Generates a function which matches node of type selector, returning an
* attribute by name if the attribute exists. If no selector is passed,
* returns attribute of the query element.
*
* @overload
* @param {string|undefined} selector Optional selector
* @param {string} name Attribute name
Expand Down

0 comments on commit f221369

Please sign in to comment.