Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types of property 'closeBundle' are incompatible. [Typescript] #17

Open
RichieRock opened this issue Apr 20, 2023 · 0 comments
Open

Types of property 'closeBundle' are incompatible. [Typescript] #17

RichieRock opened this issue Apr 20, 2023 · 0 comments

Comments

@RichieRock
Copy link

Hi!

I'm using your favicons inject plugin in my Typescript project. It seems to be working fine, but vscode is complaining about type incompability. Here's my vite.config.ts:

import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import vitePluginFaviconsInject from 'vite-plugin-favicons-inject'
import svgrPlugin from 'vite-plugin-svgr'
import viteTsconfigPaths from 'vite-tsconfig-paths'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    viteTsconfigPaths(),
    svgrPlugin(),
    vitePluginFaviconsInject('./src/assets/logo.svg'),
  ],
  server: {
    port: 3000,
    strictPort: true,
    proxy: {
      '/api': {
        target: 'http://localhost:7071/',
        changeOrigin: true,
      },
    },
  },
})

The problem is about the type of the inject plugin, it is not assignable to what vite is expecting to get.
Screenshot of vscode error:
https://pasteboard.co/geUM777Z4pbz.png

Here is the full Typescript error:

Type '{ name: string; configResolved(resolvedConfig: any): void; transformIndexHtml(html: any): Promise<any>; closeBundle(): Promise<any[]>; }' is not assignable to type 'PluginOption'.
  Type '{ name: string; configResolved(resolvedConfig: any): void; transformIndexHtml(html: any): Promise<any>; closeBundle(): Promise<any[]>; }' is not assignable to type 'Plugin_2'.
    Types of property 'closeBundle' are incompatible.
      Type '() => Promise<any[]>' is not assignable to type 'ObjectHook<(this: PluginContext) => void | Promise<void>, { sequential?: boolean | undefined; }> | undefined'.
        Type '() => Promise<any[]>' is not assignable to type '(this: PluginContext) => void | Promise<void>'.
          Type 'Promise<any[]>' is not assignable to type 'void | Promise<void>'.
            Type 'Promise<any[]>' is not assignable to type 'Promise<void>'.
              Type 'any[]' is not assignable to type 'void'.ts(2322)

Furthermore: Types of property 'closeBundle' are incompatible.

What this means, is that the closeBundle function that your plugin is returning, has returntype of Promise<any[]> whereas vite expects to have Promise<void> or just void.

Any recommendations how to get rid of the type error?

Also, any plans adding Typescript to this project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant