Skip to content

Commit

Permalink
chore: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Nov 6, 2024
1 parent 05ee84d commit 328350b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion plugins/development/plugin-theme-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"copy": "cpx \"src/**/*.d.ts\" lib"
},
"dependencies": {
"@vue/devtools-api": "^7.6.2",
"@vue/devtools-api": "^7.6.3",
"vue": "^3.5.12"
},
"peerDependencies": {
Expand Down
1 change: 0 additions & 1 deletion plugins/search/plugin-docsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"dependencies": {
"@docsearch/css": "^3.7.0",
"@docsearch/js": "^3.7.0",
"@docsearch/react": "^3.7.0",
"@vuepress/helper": "workspace:*",
"@vueuse/core": "^11.2.0",
"ts-debounce": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DocSearchProps } from '@docsearch/react'
import { debounce } from 'ts-debounce'
import { useRouter } from 'vuepress/client'
import { removeLeadingSlash, resolveRoutePathFromUrl } from 'vuepress/shared'
import type { DocSearchProps } from '../../shared/index.js'

declare const __DOCSEARCH_INDEX_BASE__: string

Expand Down Expand Up @@ -65,10 +65,11 @@ export const useDocSearchShim = (): Partial<DocSearchProps> => {
// add search debounce
transformSearchClient: (searchClient) => {
const searchWithDebounce = debounce(searchClient.search, 500)

return {
...searchClient,
search: async (...args) => searchWithDebounce(...args),
}
},
} as Partial<DocSearchProps>
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { DocSearchProps } from '@docsearch/react'
import { deepAssign, isFunction } from '@vuepress/helper/client'
import type { App, ComputedRef, InjectionKey, MaybeRefOrGetter, Ref } from 'vue'
import { computed, inject, isRef, ref, watch } from 'vue'
import { useRouteLocale } from 'vuepress/client'
import type { DocSearchOptions } from '../../shared/index.js'
import type { DocSearchOptions, DocSearchProps } from '../../shared/index.js'

declare const __VUEPRESS_DEV__: boolean
declare const __DOCSEARCH_OPTIONS__: DocSearchOptions
Expand Down Expand Up @@ -41,6 +40,7 @@ export const defineDocSearchConfig = (
docsearch.value = deepAssign({}, docSearchOptions, value)
})
} else {
// @ts-expect-error: Types loop back
docsearch.value = deepAssign({}, docSearchOptions, options)
}
}
Expand Down
8 changes: 7 additions & 1 deletion plugins/search/plugin-docsearch/src/shared/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { DocSearchProps } from '@docsearch/react'
import type docsearch from '@docsearch/js'
import type { LocaleConfig } from 'vuepress/shared'

export type DocSearchProps = typeof docsearch extends (
options: infer T,
) => unknown
? T
: never

export type DocSearchLocaleOptions = Partial<
Pick<
DocSearchProps,
Expand Down
66 changes: 34 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 328350b

Please sign in to comment.