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

After upgrading to v0.0.4: Type 'AstroIntegration' is not assignable to type AstroIntegration #355

Closed
azat-io opened this issue May 13, 2024 · 11 comments
Assignees

Comments

@azat-io
Copy link

azat-io commented May 13, 2024

Hi. I have a problem with types after upgrading the plugin to version 0.0.4.

"@playform/compress": "^0.0.4",
"astro": "^4.8.3",

Here is a part of astro.config.ts:

import compress from '@playform/compress'
import { defineConfig } from 'astro/config'

export default defineConfig({
  integrations: [
    compress({
      Exclude: [
        (file: string) => file.endsWith('.png') && !file.includes('hero.'),
      ],
      Image: process.env.COMPRESS_IMAGES !== 'false',
      JavaScript: true,
      HTML: true,
      SVG: true,
    }),
  ],
  // ...
})

I get the following error:

astro.config.ts:86:5 - error TS2322: Type 'AstroIntegration' is not assignable to type 'false | AstroIntegration | (false | AstroIntegration | null | undefined)[] | null | undefined'.
  Type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration' is not assignable to type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration'.
    The types of 'hooks['astro:config:setup']' are incompatible between these types.
      Type '(options: { config: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroConfig; ... 11 more ...; logger: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+nod...' is not assignable to type '(options: { config: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroConfig; ... 11 more ...; logger: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+nod...'.
        Types of parameters 'options' and 'options' are incompatible.
          Type '{ config: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroConfig; ... 11 more ...; logger: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11...' is not assignable to type '{ config: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroConfig; ... 11 more ...; logger: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11...'.
            The types of 'config.integrations' are incompatible between these types.
              Type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration[]' is not assignable to type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration[]'.
                Type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration' is not assignable to type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").AstroIntegration'.
                  The types of 'hooks['astro:build:ssr']' are incompatible between these types.
                    Type '(options: { manifest: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/core/app/types").SerializedSSRManifest; entryPoints: Map<...>; middlewareEntryPoint: URL | undefined; logger: import("/Users/azat/...' is not assignable to type '(options: { manifest: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/core/app/types").SerializedSSRManifest; entryPoints: Map<...>; middlewareEntryPoint: URL | undefined; logger: import("/Users/azat/...'.
                      Types of parameters 'options' and 'options' are incompatible.
                        Type '{ manifest: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/core/app/types").SerializedSSRManifest; entryPoints: Map<...>; middlewareEntryPoint: URL | undefined; logger: import("/Users/azat/Developer/...' is not assignable to type '{ manifest: import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/core/app/types").SerializedSSRManifest; entryPoints: Map<...>; middlewareEntryPoint: URL | undefined; logger: import("/Users/azat/Developer/...'.
                          Types of property 'manifest' are incompatible.
                            Type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/core/app/types").SerializedSSRManifest' is not assignable to type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/core/app/types").SerializedSSRManifest' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
                              Type 'SerializedSSRManifest' is not assignable to type 'Omit<SSRManifest, "assets" | "middleware" | "routes" | "componentMetadata" | "inlinedScripts" | "clientDirectives">' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
                                The types returned by 'pageModule.page()' are incompatible between these types.
                                  Type 'Promise<import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").ComponentInstance>' is not assignable to type 'Promise<import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").ComponentInstance>'.
                                    Type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").ComponentInstance' is not assignable to type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/@types/astro").ComponentInstance' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
                                      The types returned by 'default(...)' are incompatible between these types.
                                        Type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/runtime/server/render/astro/factory").AstroFactoryReturnValue | Promise<...>' is not assignable to type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/runtime/server/render/astro/factory").AstroFactoryReturnValue | Promise<...>'.
                                          Type 'RenderTemplateResult' is not assignable to type 'AstroFactoryReturnValue | Promise<AstroFactoryReturnValue>'.
                                            Property '[renderTemplateResultSym]' is missing in type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.1_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/runtime/server/render/astro/render-template").RenderTemplateResult' but required in type 'import("/Users/azat/Developer/azat-io/node_modules/.pnpm/astro@4.8.3_@types+node@20.12.11_lightningcss@1.24.1_terser@5.31.0_typescript@5.4.5/node_modules/astro/dist/runtime/server/render/astro/render-template").RenderTemplateResult'
@kitschpatrol
Copy link

kitschpatrol commented May 13, 2024

Same here, possibly related: #330

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 15, 2024

It stems from https://ptb.discord.com/channels/830184174198718474/1197638002764152843/1215607292792414228, somewhere in the dependency tree there are two different versions of astro being used.

@NikolaRHristov
Copy link
Member

This is a potential fix for it - #329 since it will adjust the versions accordingly.

@bennycode
Copy link
Contributor

bennycode commented May 24, 2024

I ran into this problem when upgrading from Astro 4.6.3 to 4.9.1.

Doing npm explain astro showed me that an older version of Astro is brought in by @playform/compress:

astro@"4.8.1" from @playform/compress@0.0.4

@NikolaRHristov I wonder if it comes from locking the astro peer dependency to a fix version?

https://github.com/PlayForm/Compress/blob/Current/package.json#L57

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 24, 2024

@bennycode This is the new change it will be released shortly. The previous version had astro in the dependencies key this is why it was erroring. See #329 (comment)

@NikolaRHristov
Copy link
Member

@bennycode @azat-io Should be fixed the latest astro-compress v2.2.24 and @playform/compress v0.0.6 Can you give it a go ?

@bennycode
Copy link
Contributor

Sure! Happy to test. I tried to install it but it gives me this error:

npm i @playform/compress
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @typescripttv/website@2.0.0
npm ERR! Found: @playform/document@0.0.6
npm ERR! node_modules/@playform/document
npm ERR!   peerOptional @playform/document@"0.0.6" from @playform/build@0.0.9
npm ERR!   node_modules/@playform/build
npm ERR!     peerOptional @playform/build@"0.0.9" from @playform/compress@0.0.6
npm ERR!     node_modules/@playform/compress
npm ERR!       @playform/compress@"*" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @playform/document@"0.0.7" from @playform/compress@0.0.6
npm ERR! node_modules/@playform/compress
npm ERR!   @playform/compress@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

@azat-io
Copy link
Author

azat-io commented May 24, 2024

Looks like problem was fixed in v0.0.6 👍
My package manager is pnpm.

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 24, 2024

@bennycode Thank you ! I was able to reproduce. As a hotfix I can offer you to place an .npmrc file in the project root with the following contents:

legacy-peer-deps=true

I was using it with this big .npmrc file that always auto corrects these issues. Will look into it.

@NikolaRHristov
Copy link
Member

@bennycode Should be fixed for you in the latest astro-compress v2.2.25 and @playform/compress v0.0.7

@kitschpatrol
Copy link

The type errors are now fixed on my end, thank you.

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

No branches or pull requests

4 participants