8000 TS2345: Argument of type '{}' is not assignable to parameter of type 'never' · Issue #3138 · vuejs/language-tools · GitHub
[go: up one dir, main page]

Skip to content
TS2345: Argument of type '{}' is not assignable to parameter of type 'never' #3138
Closed
@ghost

Description

After upgrading from vue-tsc@1.6.0 to 1.6.4, I get this error when running npm run type-check:

TS2345: Argument of type '{}' is not assignable to parameter of type 'never'

The error is caused by <reload-prompt />

This is the component for which the error occurs:

// ReloadPromptSsr.vue

<script setup lang="ts">
import { defineAsyncComponent } from 'vue'

const ReloadPrompt =
  typeof window !== 'undefined'
    ? defineAsyncComponent(() => import('@/components/ReloadPrompt.vue'))
    : undefined
</script>

<template>
  <template v-if="ReloadPrompt">
    <reload-prompt />
  </template>
</template>
// ReloadPrompt.vue
<script setup lang="ts">
import { ref, watch } from 'vue'
import { useRegisterSW } from '@/plugins'

const { offlineReady, needRefresh, updateServiceWorker } = useRegisterSW({
  onRegisteredSW(swScriptUrl: string, sw?: ServiceWorkerRegistration): void {
    if (!sw) return

    setInterval(() => sw.update().then(), 60000 * 5)
  },
  onRegisterError(error): void {
    console.error('Failed service worker registration:', error)
  },
  onNeedRefresh(): void {
    console.log('The app has been updated.')
  },
  onOfflineReady(): void {
    console.log('The service worker is ready to work offline.')
  }
})

const snackbar = ref<boolean>(false)

function update(value: boolean): void {
  snackbar.value = value
}

function updateSW(): void {
  updateServiceWorker().then(() => window.location.reload())
}

watch(() => offlineReady.value || needRefresh.value, update)
</script>

<template>
  <v-snackbar
    v-if="needRefresh"
    v-model="snackbar"
    location="bottom right"
    rounded="xl"
    timeout="-1"
    vertical
  >
    <div class="text-subtitle-1 pb-2">App update</div>
    <p>A new update is available.</p>

    <template v-slot:actions>
      <v-btn variant="text" @click="updateSW">Update</v-btn>
      <v-btn variant="text" @click="update(false)">Close</v-btn>
    </template>
  </v-snackbar>
</template>

<style scoped lang="scss"></style>

Used packages:

typescript: 4.9.5
vite: 4.3.5
vue: 3.2.47
vue-tsc: 1.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0