Skip to content

after upgrade from 0.8.2 to 0.9.1, receiving several errors all inside openapi-fetch #1549

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

Closed
ericblade opened this issue Feb 17, 2024 · 5 comments · Fixed by #1580
Closed
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@ericblade
Copy link

does 0.9.1 require any other updated deps?

> shx rm -rf lib/ && tsc

node_modules/openapi-fetch/dist/index.d.ts:83:42 - error TS2314: Generic type 'FetchOptions' requires 1 type argument(s).

83 export type ParseAsResponse<T, O extends FetchOptions> = O extends {
                                            ~~~~~~~~~~~~

node_modules/openapi-fetch/dist/index.d.ts:119:40 - error TS2314: Generic type 'FetchOptions' requires 1 type argument(s).

119 export type FetchResponse<T, O extends FetchOptions> =
                                           ~~~~~~~~~~~~

node_modules/openapi-fetch/dist/index.d.ts:178:36 - error TS2344: Type 'M' does not satisfy the constraint 'HttpMethod'.

178   P extends PathsWithMethod<Paths, M>,
                                       ~

  node_modules/openapi-fetch/dist/index.d.ts:177:44
    177 export type ClientMethod<Paths extends {}, M> = <
                                                   ~
    This type parameter might need an `extends HttpMethod` constraint.

node_modules/openapi-fetch/dist/index.d.ts:179:31 - error TS2344: Type 'Paths[P]' does not satisfy the constraint '{}'.
  Type 'Paths[PathsWithMethod<Paths, M>]' is not assignable to type '{}'.
    Type 'Paths[Paths[keyof Paths] extends { [K in M]: any; } ? keyof Paths : never]' is not assignable to type '{}'.
      Type 'Paths[keyof Paths]' is not assignable to type '{}'.
        Type 'Paths[string] | Paths[number] | Paths[symbol]' is not assignable to type '{}'.
          Type 'Paths[string]' is not assignable to type '{}'.

179   I extends MaybeOptionalInit<Paths[P], M>,
                                  ~~~~~~~~

node_modules/openapi-fetch/dist/index.d.ts:183:28 - error TS2536: Type 'M' cannot be used to index type 'Paths[P]'.

183 ) => Promise<FetchResponse<Paths[P][M], I[0]>>;
@ericblade ericblade added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Feb 17, 2024
@osmestad
Copy link

I'm getting the same errors, using pnpm and latest TS (https://github.com/tidal-music/tidal-sdk-web/actions/runs/7987626209/job/21810467698?pr=49)

@drwpow
Copy link
Contributor

drwpow commented Feb 21, 2024

Strange—those issues don’t appear anywhere in the project itself which is a pnpm monorepo (even installing from npm). Will try and reproduce manually, then see if there’s just something off with the TypeScript configuration in this project not catching these for some reason.

Just out of curiosity, are people with this error using ESM ("type": "module" in package.json)? Or CJS (default Node)?

@ericblade
Copy link
Author

ericblade commented Feb 21, 2024

so, all I did on that was just upgrade openapi-fetch ..

package.json:

{
  "name": "grocy-micro-ui",
  "description": "Micro UI for Grocy",
  "version": "0.0.0",
  "homepage": "",
  "private": true,
  "keywords": [
    "feathers"
  ],
  "author": {},
  "contributors": [],
  "bugs": {},
  "engines": {
    "node": ">= 20.10.0"
  },
  "feathers": {
    "language": "ts",
    "packager": "npm",
    "database": "sqlite",
    "framework": "koa",
    "transports": [
      "rest",
      "websockets"
    ],
    "schema": "typebox"
  },
  "directories": {
    "lib": "src",
    "test": "test"
  },
  "files": [
    "lib/client.js",
    "lib/**/*.d.ts",
    "lib/**/*.shared.js"
  ],
  "main": "lib/client",
  "scripts": {
    "build:openapi": "npx openapi-typescript src/grocyApi/grocyApiV4.spec.json -o src/grocyApi/grocyApiV4.d.ts && npm run bundle:client",
    "bundle:client": "npm run compile && npm pack --pack-destination ./public && cd public && npm install grocy-micro-ui-0.0.0.tgz --legacy-peer-deps",
    "compile": "shx rm -rf lib/ && tsc",
    "dev": "cross-env NODE_ENV=development nodemon -x ts-node src/index.ts",
    "start": "cross-env NODE_ENV=production node lib/",
    "mocha": "cross-env NODE_ENV=test mocha test/ --require ts-node/register --recursive --extension .ts --exit",
    "test": "cross-env NODE_ENV=test npm run migrate && npm run mocha",
    "migrate": "knex migrate:latest",
    "migrate:make": "knex migrate:make",
    "upgrade-deps": "npx npm-check-updates -u --doctor"
  },
  "dependencies": {
    "@feathersjs/adapter-commons": "^5.0.22",
    "@feathersjs/authentication": "^5.0.22",
    "@feathersjs/authentication-client": "^5.0.22",
    "@feathersjs/authentication-local": "^5.0.22",
    "@feathersjs/authentication-oauth": "^5.0.22",
    "@feathersjs/configuration": "^5.0.22",
    "@feathersjs/errors": "^5.0.22",
    "@feathersjs/feathers": "^5.0.22",
    "@feathersjs/knex": "^5.0.22",
    "@feathersjs/koa": "^5.0.22",
    "@feathersjs/schema": "^5.0.22",
    "@feathersjs/socketio": "^5.0.22",
    "@feathersjs/transport-commons": "^5.0.22",
    "@feathersjs/typebox": "^5.0.22",
    "cross-env": "^7.0.3",
    "knex": "^3.1.0",
    "openapi-fetch": "^0.8.2",
    "sqlite3": "^5.1.7",
    "winston": "^3.11.0"
  },
  "devDependencies": {
    "@feathersjs/cli": "^5.0.22",
    "@feathersjs/rest-client": "^5.0.22",
    "@types/mocha": "^10.0.6",
    "@types/node": "^20.11.19",
    "axios": "^1.6.7",
    "mocha": "^10.3.0",
    "nodemon": "^3.0.3",
    "openapi-typescript": "^6.7.4",
    "prettier": "^3.2.5",
    "shx": "^0.3.4",
    "ts-node": "^10.9.2",
    "typescript": "^5.3.3"
  }
}

I see there's a 0.9.2 now, going to give it a look

Looks like it's the same output

G:\grocy-micro-ui>npm run compile

[email protected] compile
shx rm -rf lib/ && tsc

node_modules/openapi-fetch/dist/index.d.ts:83:42 - error TS2314: Generic type 'FetchOptions' requires 1 type argument(s).

83 export type ParseAsResponse<T, O extends FetchOptions> = O extends {
                                            ~~~~~~~~~~~~

node_modules/openapi-fetch/dist/index.d.ts:119:40 - error TS2314: Generic type 'FetchOptions' requires 1 type argument(s).

119 export type FetchResponse<T, O extends FetchOptions> =
                                           ~~~~~~~~~~~~

node_modules/openapi-fetch/dist/index.d.ts:178:36 - error TS2344: Type 'M' does not satisfy the constraint 'HttpMethod'.

178   P extends PathsWithMethod<Paths, M>,
                                       ~

  node_modules/openapi-fetch/dist/index.d.ts:177:44
    177 export type ClientMethod<Paths extends {}, M> = <
                                                   ~
    This type parameter might need an `extends HttpMethod` constraint.

node_modules/openapi-fetch/dist/index.d.ts:179:31 - error TS2344: Type 'Paths[P]' does not satisfy the constraint '{}'.
  Type 'Paths[PathsWithMethod<Paths, M>]' is not assignable to type '{}'.
    Type 'Paths[Paths[keyof Paths] extends { [K in M]: any; } ? keyof Paths : never]' is not assignable to type '{}'.
      Type 'Paths[keyof Paths]' is not assignable to type '{}'.
        Type 'Paths[string] | Paths[number] | Paths[symbol]' is not assignable to type '{}'.
          Type 'Paths[string]' is not assignable to type '{}'.

179   I extends MaybeOptionalInit<Paths[P], M>,
                                  ~~~~~~~~

node_modules/openapi-fetch/dist/index.d.ts:183:28 - error TS2536: Type 'M' cannot be used to index type 'Paths[P]'.

183 ) => Promise<FetchResponse<Paths[P][M], I[0]>>;
                               ~~~~~~~~~~~


Found 5 errors in the same file, starting at: node_modules/openapi-fetch/dist/index.d.ts:83

Dropping back to 0.8.2, no errors found

G:\grocy-micro-ui>npm run compile

[email protected] compile
shx rm -rf lib/ && tsc


G:\grocy-micro-ui>

@ozfox
Copy link

ozfox commented Feb 23, 2024

Strange—those issues don’t appear anywhere in the project itself which is a pnpm monorepo (even installing from npm). Will try and reproduce manually, then see if there’s just something off with the TypeScript configuration in this project not catching these for some reason.

I guess this is because skipLibCheck is set in tsconfig.json?

It seems that 0.8.2 did build without "skipLibCheck": true, but 0.9.x doesn't.

Just out of curiosity, are people with this error using ESM ("type": "module" in package.json)? Or CJS (default Node)?

I am using ESM ("type": "module")

@drwpow
Copy link
Contributor

drwpow commented Feb 23, 2024

It seems that 0.8.2 did build without "skipLibCheck": true, but 0.9.x doesn't.

Ah that’s really helpful info, thank you. To be honest I can’t seem to get away from that setting in any of my projects; there’s always at least 1 package with type errors (sometimes caused by unexpected package version combinations). But better to not be part of the problem I suppose!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants