lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.33k stars 481 forks source link

The latest version 6.1.4 causes new build issues. #1590

Closed JimmyBjorklund closed 3 weeks ago

JimmyBjorklund commented 4 months ago

The latest version 6.1.4 causes new build issues.

0.932 > tsc 0.932 3.885 node_modules/@hapi/hapi/lib/types/route.d.ts:2:68 - error TS2307: Cannot find module 'joi' or its corresponding type declarations. 3.885 3.885 2 import { ObjectSchema, ValidationOptions, SchemaMap, Schema } from 'joi'; 3.885 ~ 3.885 3.887 node_modules/@hapi/hapi/lib/types/server/server.d.ts:4:22 - error TS2307: Cannot find module 'joi' or its corresponding type declarations. 3.887 3.887 4 import { Root } from 'joi'; 3.887 ~ 3.887 3.887 node_modules/@tsoa/runtime/dist/routeGeneration/templates/koa/koaTemplateService.d.ts:1:36 - error TS7016: Could not find a declaration file for module 'koa'. '/usr/src/app/node_modules/koa/lib/application.js' implicitly has an 'any' type. 3.887 Try npm i --save-dev @types/koa if it exists or add a new declaration (.d.ts) file containing declare module 'koa'; 3.887 3.887 1 import type { Context, Next } from 'koa'; 3.887 ~

WoH commented 4 months ago

Seems like skipLibCheck is false explicitly? I'm not sure, but the joi part seems more like an issue with hapi's type declarations. Not sure about koa though

WoH commented 4 months ago

935af8e will fix koa.

jackey8616 commented 3 months ago

Seems like skipLibCheck is false explicitly? I'm not sure, but the joi part seems more like an issue with hapi's type declarations. Not sure about koa though

Confirm: When I try to reproduce #1594, I create another clean repo using tsoa@6.1.5 locally. skipLibCheck is false in default, after I explicitly set it to true, the joi import error gone.

Detail tsconfig.json

{
  "compilerOptions": {
    /* Basic Options */
    "incremental": true,
    "target": "es6",
    "module": "commonjs",
    "outDir": "build",

    /* Strict Type-Checking Options */
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictBindCallApply": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,

    /* Additional Checks */
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,

    /* Module Resolution Options */
    "moduleResolution": "node",
    "baseUrl": ".",
    "esModuleInterop": true,

    /* Experimental Options */
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,

    /* Advanced Options */
    "forceConsistentCasingInFileNames": true,

    "resolveJsonModule": true
  }
}
WoH commented 3 months ago

@JimmyBjorklund what package manager are you using?

lgoeckener commented 3 months ago

I am having a similar issue with the latest version 6.1.5

backend-1   | ../node_modules/@hapi/hapi/lib/types/route.d.ts(2,68): error TS2307: Cannot find module 'joi' or its corresponding type declarations.
backend-1   | ../node_modules/@hapi/hapi/lib/types/server/server.d.ts(4,22): error TS2307: Cannot find module 'joi' or its corresponding type declarations.

skipLibCheck is turned off, but it doesn't feel good to me, to turn that on on production level.

Using npm (v10.2.4) on arm64v8/node:20.11.1-alpine3.19 (running on M1 Pro)

JimmyBjorklund commented 3 months ago

@JimmyBjorklund what package manager are you using? npm --version 10.2.3 node --version v20.10.0

WoH commented 3 months ago

I am having a similar issue with the latest version 6.1.5

backend-1   | ../node_modules/@hapi/hapi/lib/types/route.d.ts(2,68): error TS2307: Cannot find module 'joi' or its corresponding type declarations.
backend-1   | ../node_modules/@hapi/hapi/lib/types/server/server.d.ts(4,22): error TS2307: Cannot find module 'joi' or its corresponding type declarations.

skipLibCheck is turned off, but it doesn't feel good to me, to turn that on on production level.

Using npm (v10.2.4) on arm64v8/node:20.11.1-alpine3.19 (running on M1 Pro)

You can always add joi to (dev)Deps yourself. That would be a fix we can also to, but it doesn't feel great.

WoH commented 3 months ago

Thanks @JimmyBjorklund for opening an issue over at the hapi repo: https://github.com/hapijs/hapi/issues/4491

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

JimmyBjorklund commented 2 months ago

Still an issue

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

ClementValot commented 1 month ago

Still an issue :/

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

WoH commented 3 weeks ago

If someone has a good way to fix this on our side, I'll reopen. The way I see it, add joi and don't use it, just to satisfy the type checker, declare it as any, or skip checking on it.