Skip to content

Invalid types using @tsconfig/node20 #1824

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
javialon26 opened this issue Aug 7, 2024 · 2 comments · Fixed by #1827
Closed

Invalid types using @tsconfig/node20 #1824

javialon26 opened this issue Aug 7, 2024 · 2 comments · Fixed by #1827

Comments

@javialon26
Copy link

javialon26 commented Aug 7, 2024

It looks like extending the tsconfig.json file from @tsconfig/node20 is causing type errors, particularly with the second argument (options) on routes and with parameters like params, body, headers, etc., not appearing in VSCode IntelliSense. However, when you remove the lib: ["es2023"] setting, everything works as expected.

Reference #1749

Packages versions:
"openapi-fetch": "^0.10.5",
"openapi-typescript": "^7.3.0",
"typescript": "^5.5.4"

Generator script:
"generate:client": "openapi-typescript https://petstore3.swagger.io/api/v3/openapi.yaml -o ./src/lib/client.d.ts",

@javialon26 javialon26 changed the title Invalid types using [@tsconfig/node20 tsconfig.json](https://www.npmjs.com/package/@tsconfig/node20) Invalid types using @tsconfig/node20 Aug 7, 2024
@javialon26
Copy link
Author

javialon26 commented Aug 7, 2024

tsconfig.json

{
  "extends": "@tsconfig/node20/tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist"
  },
  "include": ["src"]
}

Example using pet store swagger file and lib: ['ES2023']:

Screenshot 2024-08-07 at 2 33 52 AM

Example using pet store swagger file without lib:

Screenshot 2024-08-07 at 2 35 49 AM

@ngraef
Copy link
Contributor

ngraef commented Aug 7, 2024

This appears to be broken by a change in [email protected], specifically microsoft/TypeScript#58610, which first shipped in [email protected]. However, the underlying cause is the typing issue noted in #1823.

I can reproduce this issue in a project with:

  • typescript@>=5.5
  • @types/node@>=18
  • tsconfig.json declares (or extends a config with) a lib array that does not include "DOM"

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

Successfully merging a pull request may close this issue.

2 participants