diff --git a/package.json b/package.json index d4dd1c3b..841a0fd6 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0-alpha.4", "description": "Vite & Vue powered static site generator", "type": "module", - "packageManager": "pnpm@7.4.1", + "packageManager": "pnpm@7.5.0", "main": "dist/node/index.js", "types": "types/index.d.ts", "exports": { diff --git a/src/client/app/composables/preFetch.ts b/src/client/app/composables/preFetch.ts index e35bcecb..201a3934 100644 --- a/src/client/app/composables/preFetch.ts +++ b/src/client/app/composables/preFetch.ts @@ -49,7 +49,7 @@ export function usePrefetch() { return } - const rIC = (window as any).requestIdleCallback || setTimeout + const rIC = window.requestIdleCallback || setTimeout let observer: IntersectionObserver | null = null const observeLinks = () => { @@ -73,8 +73,8 @@ export function usePrefetch() { }) rIC(() => { - document.querySelectorAll('#app a').forEach((link) => { - const { target, hostname, pathname } = link as HTMLAnchorElement + document.querySelectorAll('#app a').forEach((link) => { + const { target, hostname, pathname } = link const extMatch = pathname.match(/\.\w+$/) if (extMatch && extMatch[0] !== '.html') { return diff --git a/src/client/app/router.ts b/src/client/app/router.ts index c82bb66c..40d91146 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -64,7 +64,7 @@ export function createRouter( if (latestPendingPath === pendingPath) { latestPendingPath = null - const { default: comp, __pageData } = page as PageModule + const { default: comp, __pageData } = page if (!comp) { throw new Error(`Invalid route component: ${comp}`) } @@ -82,7 +82,7 @@ export function createRouter( try { target = document.querySelector( decodeURIComponent(targetLoc.hash) - ) as HTMLElement + ) } catch (e) { console.warn(e) } @@ -190,7 +190,7 @@ export function useRoute(): Route { } function scrollTo(el: HTMLElement, hash: string, smooth = false) { - let target: Element | null = null + let target: HTMLElement | null = null try { target = el.classList.contains('header-anchor') @@ -207,12 +207,12 @@ function scrollTo(el: HTMLElement, hash: string, smooth = false) { document.querySelector(offset)!.getBoundingClientRect().bottom + 24 } const targetPadding = parseInt( - window.getComputedStyle(target as HTMLElement).paddingTop, + window.getComputedStyle(target).paddingTop, 10 ) const targetTop = window.scrollY + - (target as HTMLElement).getBoundingClientRect().top - + target.getBoundingClientRect().top - offset + targetPadding // only smooth scroll if distance is smaller than screen height. diff --git a/src/client/theme-default/components/VPAlgoliaSearchBox.vue b/src/client/theme-default/components/VPAlgoliaSearchBox.vue index 31610845..a2eb314d 100644 --- a/src/client/theme-default/components/VPAlgoliaSearchBox.vue +++ b/src/client/theme-default/components/VPAlgoliaSearchBox.vue @@ -64,7 +64,7 @@ function initialize(userOptions: DefaultTheme.AlgoliaSearchOptions) { // @ts-ignore hitComponent({ hit, children }) { const relativeHit = hit.url.startsWith('http') - ? getRelativePath(hit.url as string) + ? getRelativePath(hit.url) : hit.url return { diff --git a/src/client/theme-default/components/VPDocAsideOutline.vue b/src/client/theme-default/components/VPDocAsideOutline.vue index b4b17908..157a54f1 100644 --- a/src/client/theme-default/components/VPDocAsideOutline.vue +++ b/src/client/theme-default/components/VPDocAsideOutline.vue @@ -22,7 +22,7 @@ const resolvedHeaders = computed(() => { function handleClick({ target: el }: Event) { const id = '#' + (el as HTMLAnchorElement).href!.split('#')[1] - const heading = document.querySelector(id) as HTMLAnchorElement + const heading = document.querySelector(id) heading?.focus() } diff --git a/src/client/theme-default/components/VPSkipLink.vue b/src/client/theme-default/components/VPSkipLink.vue index 5324e8bd..492e0148 100644 --- a/src/client/theme-default/components/VPSkipLink.vue +++ b/src/client/theme-default/components/VPSkipLink.vue @@ -8,9 +8,9 @@ const backToTop = ref() watch(() => route.path, () => backToTop.value.focus()) function focusOnTargetAnchor({ target }: Event) { - const el = document.querySelector( - (target as HTMLAnchorElement).hash! - ) as HTMLAnchorElement + const el = document.querySelector( + (target as HTMLAnchorElement).hash + ) if (el) { const removeTabIndex = () => { diff --git a/src/client/theme-default/composables/flyout.ts b/src/client/theme-default/composables/flyout.ts index f71c1d54..691c5958 100644 --- a/src/client/theme-default/composables/flyout.ts +++ b/src/client/theme-default/composables/flyout.ts @@ -20,7 +20,7 @@ export function useFlyout(options: UseFlyoutOptions) { listeners++ const unwatch = watch(focusedElement, (el) => { - if (el === options.el.value || options.el.value?.contains(el as Node)) { + if (el === options.el.value || options.el.value?.contains(el!)) { focus.value = true options.onFocus?.() } else { diff --git a/src/client/theme-default/composables/outline.ts b/src/client/theme-default/composables/outline.ts index 698aeda6..4b891f39 100644 --- a/src/client/theme-default/composables/outline.ts +++ b/src/client/theme-default/composables/outline.ts @@ -135,7 +135,7 @@ export function useActiveAnchor( if (hash !== null) { prevActiveLink = container.value.querySelector( `a[href="${decodeURIComponent(hash)}"]` - ) as HTMLAnchorElement + ) } const activeLink = prevActiveLink diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index dceab459..bd37554a 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -139,7 +139,7 @@ export async function bundle( } // build