frouriojs / frourio

Fast and type-safe full stack framework, for TypeScript
https://frourio.com
MIT License
1.22k stars 24 forks source link

Does frourio support pnpm? #278

Closed arx-8 closed 1 year ago

arx-8 commented 1 year ago

Description

After replacing npm with pnpm, I am getting an error in typecheck. Is there any way to work around this?

Minimum project for repro. https://github.com/arx-8/try-frourio-ts

Please see each of the commits below; after replacing to pnpm, a type error occurs. https://github.com/arx-8/try-frourio-ts/commits/main

The actual error messages are described below.

Environment

Additional context

I created the project with the following settings. (In practice, this command may not work because I used the create-frourio-app GUI.)

npm init frourio-app --answers '{
  "dir": "frourio-app",
  "server": "fastify",
  "client": "next",
  "building": "static",
  "mode": "spa",
  "target": "static",
  "aspida": "axios",
  "reactHooks": "none",
  "daemon": "none",
  "orm": "prisma",
  "db": "postgresql",
  "postgresqlDbHost": "localhost",
  "postgresqlDbPort": "5432",
  "testing": "jest",
  "pm": "npm",
  "ci": "actions",
  "deployServer": "none",
  "deployBranch": "main",
  "serverSourcePath": "/opt/apiserver",
}'

pnpm run typecheck result

$ pnpm run typecheck

> frourio-app@0.1.0 typecheck /Users/arx/study/try-frourio2
> tsc --noEmit && tsc --noEmit -p server

jest.config.ts:2:29 - error TS2307: Cannot find module '@jest/types' or its corresponding type declarations.

2 import type { Config } from '@jest/types'
                              ~~~~~~~~~~~~~

server/api/$api.ts:1:49 - error TS2307: Cannot find module 'aspida' or its corresponding type declarations.

1 import type { AspidaClient, BasicHeaders } from 'aspida'
                                                  ~~~~~~~~

server/api/$api.ts:2:33 - error TS2307: Cannot find module 'aspida' or its corresponding type declarations.

2 import { dataToURLString } from 'aspida'
                                  ~~~~~~~~

server/api/$api.ts:31:89 - error TS7006: Parameter 'r' implicitly has an 'any' type.

31             fetch<Methods2['get']['resBody']>(prefix, prefix1, GET, option).json().then(r => r.body),
                                                                                           ~

server/api/$api.ts:38:83 - error TS7006: Parameter 'r' implicitly has an 'any' type.

38         fetch<Methods1['get']['resBody']>(prefix, PATH0, GET, option).json().then(r => r.body),
                                                                                     ~

server/api/$api.ts:50:112 - error TS7006: Parameter 'r' implicitly has an 'any' type.

50             fetch<void, BasicHeaders, Methods4['patch']['status']>(prefix, prefix1, PATCH, option).send().then(r => r.body),
                                                                                                                  ~

server/api/$api.ts:54:114 - error TS7006: Parameter 'r' implicitly has an 'any' type.

54             fetch<void, BasicHeaders, Methods4['delete']['status']>(prefix, prefix1, DELETE, option).send().then(r => r.body),
                                                                                                                    ~

server/api/$api.ts:61:83 - error TS7006: Parameter 'r' implicitly has an 'any' type.

61         fetch<Methods3['get']['resBody']>(prefix, PATH1, GET, option).json().then(r => r.body),
                                                                                     ~

server/api/$api.ts:65:85 - error TS7006: Parameter 'r' implicitly has an 'any' type.

65         fetch<Methods3['post']['resBody']>(prefix, PATH1, POST, option).json().then(r => r.body),
                                                                                       ~

server/api/$api.ts:73:85 - error TS7006: Parameter 'r' implicitly has an 'any' type.

73         fetch<Methods5['post']['resBody']>(prefix, PATH2, POST, option).json().then(r => r.body),
                                                                                       ~

server/api/$api.ts:80:83 - error TS7006: Parameter 'r' implicitly has an 'any' type.

80         fetch<Methods6['get']['resBody']>(prefix, PATH3, GET, option).json().then(r => r.body),
                                                                                     ~

server/api/$api.ts:84:97 - error TS7006: Parameter 'r' implicitly has an 'any' type.

84         fetch<Methods6['post']['resBody']>(prefix, PATH3, POST, option, 'FormData').json().then(r => r.body),
                                                                                                   ~

server/api/$api.ts:90:78 - error TS7006: Parameter 'r' implicitly has an 'any' type.

90       fetch<Methods0['get']['resBody']>(prefix, '', GET, option).text().then(r => r.body),
                                                                                ~

server/api/tasks/_taskId@number/index.ts:1:27 - error TS2307: Cannot find module '$prisma/client' or its corresponding type declarations.

1 import type { Task } from '$prisma/client'
                            ~~~~~~~~~~~~~~~~

server/api/tasks/index.ts:1:27 - error TS2307: Cannot find module '$prisma/client' or its corresponding type declarations.

1 import type { Task } from '$prisma/client'
                            ~~~~~~~~~~~~~~~~

src/pages/article/entry.tsx:20:14 - error TS7006: Parameter 'article' implicitly has an 'any' type.

20       .then((article) => {
                ~~~~~~~

src/pages/article/index.tsx:25:57 - error TS7006: Parameter 'articleList' implicitly has an 'any' type.

25     apiClient.article.$get({ query: { search } }).then((articleList) => {
                                                           ~~~~~~~~~~~

src/pages/index.tsx:5:27 - error TS2307: Cannot find module '$prisma/client' or its corresponding type declarations.

5 import type { Task } from '$prisma/client'
                            ~~~~~~~~~~~~~~~~

Found 18 errors in 7 files.

Errors  Files
     1  jest.config.ts:2
    12  server/api/$api.ts:1
     1  server/api/tasks/_taskId@number/index.ts:1
     1  server/api/tasks/index.ts:1
     1  src/pages/article/entry.tsx:20
     1  src/pages/article/index.tsx:25
     1  src/pages/index.tsx:5
 ELIFECYCLE  Command failed with exit code 2.
arx-8 commented 1 year ago

I made the following changes and had success with pnpm. https://github.com/arx-8/try-frourio-ts/commit/605f5a9c69357265e38671945309438c6b8055fa

It appears that the problem is a combination of the following:

The tsc does not seem to be able to read the type info of grandchildren and their great-grandchildren of dependencies installed by pnpm.🤔 I was able to avoid that by setting up node-linker="hoisted". I don't understand the side effects of the node-linker="hoisted" setting, but at least it doesn't seem to be a frourio problem.

I apologize if I have caused you to do any unnecessary research, but I hope this issue will be of use to someone. 🙏