blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Unable to compile TypeScript on `blitz install [recipe]` #390

Closed tbosch82 closed 2 years ago

tbosch82 commented 2 years ago

What is the problem?

blitz install [recipe] fails with an Unable to compile TypeScript error when attempting to run in a TypeScript project. I initially noticed when attempting to add material-ui but it appears to be failing on other recipes as well.

Paste all your error logs here:

TSError: ⨯ Unable to compile TypeScript:
    .blitz/recipe-install/index.ts:39:5 - error TS2322: Type '(program: Collection<Program>) => Collection<Program>'
    is not assignable to type 'Transformer'.
      Types of parameters 'program' and 'program' are incompatible.
        Type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/n
    ode_modules/@types/jscodeshift/src/Collection").Collection<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz
    /recipe-install/node_modules/@blitzjs/installer/node_modules/ast-types/gen/nodes").Program>' is not assignable to
    type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@types/jscodeshift/src/c
    ore").Collection<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-types/gen
    /namedTypes").namedTypes.Program>'.
          Types of property 'filter' are incompatible.
            Type '{ <S extends import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@bl
    itzjs/installer/node_modules/ast-types/gen/nodes").Program>(callback: (path: ASTPath<import("D:/JustCook/Github/ma
    rket-pwa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/node_modules/ast-types/gen/no...' is not
     assignable to type '{ <S extends import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modu
    les/ast-types/gen/namedTypes").namedTypes.Program>(callback: (path: ASTPath<import("D:/JustCook/Github/market-pwa/
    market-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.Program>, i: number,
    paths...'.
              Types of parameters 'callback' and 'callback' are incompatible.
                Type '(path: ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modul
    es/ast-types/gen/namedTypes").namedTypes.Program>, i: number, paths: ASTPath<...>[]) => path is ASTPath<...>' is
    not assignable to type '(path: ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node
    _modules/@blitzjs/installer/node_modules/ast-types/gen/nodes").Program>, i: number, paths: ASTPath<...>[]) => path
     is ASTPath<...>'.
                  Types of parameters 'path' and 'path' are incompatible.
                    Type 'ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/
    @blitzjs/installer/node_modules/ast-types/gen/nodes").Program>' is not assignable to type
    'ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTy
    pes").namedTypes.Program>'.
                      The types of 'node.body' are incompatible between these types.
                        Type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@bli
    tzjs/installer/node_modules/ast-types/gen/kinds").StatementKind[]' is not assignable to type 'import("D:/JustCook/
    Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-types/gen/kinds").StatementKind[]'.
                          Type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@b
    litzjs/installer/node_modules/ast-types/gen/kinds").StatementKind' is not assignable to type 'import("D:/JustCook/
    Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-types/gen/kinds").StatementKind'.
                            Type 'BlockStatement' is not assignable to type 'StatementKind'.

    39     transform(program: j.Collection<j.Program>) {
           ~~~~~~~~~

      .blitz/recipe-install/node_modules/@blitzjs/installer/dist/declarations/src/executors/file-transform-executor.d.
    ts:6:5
        6     transform?: Transformer;
              ~~~~~~~~~
        The expected type comes from property 'transform' which is declared here on type 'Omit<Config, "stepType">'
    .blitz/recipe-install/index.ts:177:19 - error TS2345: Argument of type 'import("D:/JustCook/Github/market-pwa/mark
    et-pwa/.blitz/recipe-install/node_modules/@types/jscodeshift/src/core").Collection<import("D:/JustCook/Github/mark
    et-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.Program>' is not
    assignable to parameter of type
    'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/node_modul
    es/@types/jscodeshift/src/Collection").Collection<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-i
    nstall/node_modules/@blitzjs/installer/node_modules/ast-types/gen/nodes").Program>'.
      Types of property 'filter' are incompatible.
        Type '{ <S extends import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-typ
    es/gen/namedTypes").namedTypes.Program>(callback: (path: ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/
    .blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.Program>, i: number, paths...' is not
    assignable to type '{ <S extends import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modul
    es/@blitzjs/installer/node_modules/ast-types/gen/nodes").Program>(callback: (path: ASTPath<import("D:/JustCook/Git
    hub/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/node_modules/ast-types/gen/no...'.
          Types of parameters 'callback' and 'callback' are incompatible.
            Type '(path: ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@
    blitzjs/installer/node_modules/ast-types/gen/nodes").Program>, i: number, paths: ASTPath<...>[]) => path is
    ASTPath<...>' is not assignable to type '(path: ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/re
    cipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.Program>, i: number, paths: ASTPath<...>[]) =>
    path is ASTPath<...>'.
              Types of parameters 'path' and 'path' are incompatible.
                Type 'ASTPath<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-
    types/gen/namedTypes").namedTypes.Program>' is not assignable to type 'ASTPath<import("D:/JustCook/Github/market-p
    wa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/node_modules/ast-types/gen/nodes").Program>'.
                  The types of 'node.body' are incompatible between these types.
                    Type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-type
    s/gen/kinds").StatementKind[]' is not assignable to type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/
    recipe-install/node_modules/@blitzjs/installer/node_modules/ast-types/gen/kinds").StatementKind[]'.
                      Type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-ty
    pes/gen/kinds").StatementKind' is not assignable to type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/
    recipe-install/node_modules/@blitzjs/installer/node_modules/ast-types/gen/kinds").StatementKind'.
                        Type 'BlockStatement' is not assignable to type 'StatementKind'.
                          Type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/as
    t-types/gen/namedTypes").namedTypes.BlockStatement' is not assignable to type
    'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/node_modul
    es/ast-types/gen/nodes").BlockStatement'.
                            Types of property 'directives' are incompatible.
                              Type 'Directive[] | undefined' is not assignable to type 'Directive[]'.
                                Type 'undefined' is not assignable to type 'Directive[]'.

    177         addImport(program, reactImport)
                          ~~~~~~~
    .blitz/recipe-install/index.ts:180:17 - error TS2345: Argument of type 'import("D:/JustCook/Github/market-pwa/mark
    et-pwa/.blitz/recipe-install/node_modules/@types/jscodeshift/src/core").Collection<import("D:/JustCook/Github/mark
    et-pwa/market-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.Program>' is not
    assignable to parameter of type
    'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modules/@blitzjs/installer/node_modul
    es/@types/jscodeshift/src/Collection").Collection<import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-i
    nstall/node_modules/@blitzjs/installer/node_modules/ast-types/gen/nodes").Program>'.

    180       addImport(program, serverStyleSheetsImport)
                        ~~~~~~~
    .blitz/recipe-install/index.ts:206:26 - error TS2345: Argument of type 'import("D:/JustCook/Github/market-pwa/mark
    et-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.ImportDeclaration' is not
    assignable to parameter of type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modul
    es/@blitzjs/installer/node_modules/ast-types/gen/nodes").ImportDeclaration'.
      Types of property 'specifiers' are incompatible.
        Type '(ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier)[] | undefined' is not assignable
    to type '(ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier)[]'.
          Type 'undefined' is not assignable to type '(ImportSpecifier | ImportNamespaceSpecifier |
    ImportDefaultSpecifier)[]'.

    206       addImport(program, cssBaselineImport)
                                 ~~~~~~~~~~~~~~~~~
    .blitz/recipe-install/index.ts:207:26 - error TS2345: Argument of type 'import("D:/JustCook/Github/market-pwa/mark
    et-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.ImportDeclaration' is not
    assignable to parameter of type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modul
    es/@blitzjs/installer/node_modules/ast-types/gen/nodes").ImportDeclaration'.

    207       addImport(program, themeImport)
                                 ~~~~~~~~~~~
    .blitz/recipe-install/index.ts:337:28 - error TS2345: Argument of type 'import("D:/JustCook/Github/market-pwa/mark
    et-pwa/.blitz/recipe-install/node_modules/ast-types/gen/namedTypes").namedTypes.ImportDeclaration' is not
    assignable to parameter of type 'import("D:/JustCook/Github/market-pwa/market-pwa/.blitz/recipe-install/node_modul
    es/@blitzjs/installer/node_modules/ast-types/gen/nodes").ImportDeclaration'.

    337         addImport(program, reactImport)

Paste all relevant code snippets here:

NA

What are detailed steps to reproduce this?

  1. Start new Blitz app (bare or full, TypeScript, Yarn, Final form)
  2. run blitz install material-ui

Run blitz -v and paste the output here:

Windows 10 | win32-x64 | Node: v16.10.0

blitz: 0.42.4 (global)
blitz: 0.42.4 (local)

  Package manager: yarn
  System:
    OS: Windows 10 10.0.19042
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 18.22 GB / 31.92 GB
  Binaries:
    Node: 16.10.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - D:\Program Files\nodejs\yarn.CMD
    npm: 7.24.0 - D:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.4.2 => 3.4.2
    blitz: 0.42.4 => 0.42.4
    prisma: 3.4.2 => 3.4.2
    react: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
    react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
    typescript: ~4.4 => 4.4.4

Please include below any other applicable logs and screenshots that show your problem:

No response

ugogo commented 2 years ago

Same with blitz install chakra-ui 👍

strocchia commented 2 years ago

Same for me on Mac with blitz install tailwind :

macOS High Sierra | darwin-x64 | Node: v14.15.3

blitz: 0.42.4 (global)
blitz: 0.41.0 (local)

  Package manager: yarn
  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz
    Memory: 22.97 MB / 4.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 14.15.3 - /usr/local/bin/node
    Yarn: 1.22.5 - ~/.yarn/bin/yarn
    npm: 6.14.9 - /usr/local/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.2.1 => 3.2.1
    blitz: 0.41.0 => 0.41.0
    prisma: 3.2.1 => 3.2.1
    react: alpha => 18.0.0-alpha-55d75005b-20211011
    react-dom: alpha => 18.0.0-alpha-55d75005b-20211011
    typescript: ~4.3 => 4.3.5
alcance commented 2 years ago

Same issue. Any solution for this ?

blitz: 0.42.0 (global)
blitz: 0.42.0 (local)

  Package manager: yarn
  System:
    OS: macOS 12.0.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 204.16 MB / 8.00 GB
    Shell: 3.3.1 - /usr/local/bin/fish
  Binaries:
    Node: 17.0.1 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.4.1 => 3.4.1
    blitz: 0.42.0 => 0.42.0
    prisma: 3.4.1 => 3.4.1
    react: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
    react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
    typescript: ~4.4 => 4.4.4