Skip to content

Commit e77f019

Browse files
committed
fix: 🐛 修正类型推导
1 parent fffbec0 commit e77f019

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

libs/xpath-selector/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @xiaohuohumax/xpath-selector
22

3+
## 1.0.6
4+
5+
### Patch Changes
6+
7+
- 修正类型推导
8+
39
## 1.0.5
410

511
### Patch Changes

libs/xpath-selector/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ const title = xpathSelector({
173173
})
174174

175175
console.log(title) // Output: "Test Page"
176+
177+
const links = xpathSelector<HTMLAnchorElement, 'nodes'>({
178+
expression: '//a',
179+
returnType: 'nodes',
180+
})
181+
182+
console.log(links) // Output: [<a href="#">Hello</a>, <a href="#">World</a>]
176183
```
177184

178185
4. 修改 vite.config.ts 排除 xpath-selector 依赖

libs/xpath-selector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@xiaohuohumax/xpath-selector",
33
"type": "module",
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"description": "XPath Selector -- 一个 XPath 选择器库,快速获取节点数据",
66
"author": {
77
"name": "xiaohuohumax",

libs/xpath-selector/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function returnTypeTransition<T extends ReturnType>(returnType: T): ReturnTypeTr
5252
return returnTypeMap[returnType]
5353
}
5454

55-
export default function xpathSelector<T extends ReturnType>(options: Options<T>) {
56-
return fontoxpath.evaluateXPath<fontoxpath.Node, ReturnTypeTransition<T>>(
55+
export default function xpathSelector<N extends fontoxpath.Node, T extends ReturnType>(options: Options<T>) {
56+
return fontoxpath.evaluateXPath<N, ReturnTypeTransition<T>>(
5757
options.expression,
5858
options.node || document,
5959
null,

0 commit comments

Comments
 (0)