Skip to content
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

[BUG] Cannot find module '@tsed/platform-http/testing' or its corresponding type declarations. #2928

Closed
vangie opened this issue Dec 9, 2024 · 7 comments
Assignees
Labels

Comments

@vangie
Copy link
Contributor

vangie commented Dec 9, 2024

Describe the bug

src/services/job.service.integration.spec.ts:1:30 - error TS2307: Cannot find module '@tsed/platform-http/testing' or its corresponding type declarations.
  There are types at '/Users/duwan/Workspaces/babelcloud/babel-agent/node_modules/.pnpm/@tsed+common@8.3.0_@tsed+engines@8.3.0_@tsed+logger-file@7.0.1_@tsed+logger@7.0.1__@tsed+logg_av3w5gjbnsdwb4zqi636wx5qdi/node_modules/@tsed/platform-http/lib/types/testing/index.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

1 import { PlatformTest } from "@tsed/platform-http/testing";
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To Reproduce

  1. upgrade tsed from v7 to v8
  2. replace import {PlatformTest} from "@tsed/common" by import {PlatformTest} from "@tsed/platform-http/testing"
  3. run npx tsc --noEmit

tsconfig.json

{
  "compilerOptions": {
    "noEmit": true,
    "tsBuildInfoFile": "./dist/.tsbuildinfo",
    "incremental": true,
    /* Language and Environment */
    "target": "esnext",
    "lib": ["ESNext"],
    "moduleDetection": "force",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "useDefineForClassFields": false,
    /* Modules */
    "module": "ESNext",
    "moduleResolution": "node",
    "paths": {
      "#*": ["./src/*"],
      "#services": ["./src/services"],
      "#services/*": ["./src/services/*"]
    },
    "resolveJsonModule": true,
    "allowArbitraryExtensions": false,
    "allowImportingTsExtensions": false,
    "allowUmdGlobalAccess": false,
    "types": ["node"],
    /* Interop Constraints */
    "verbatimModuleSyntax": false,
    "isolatedModules": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    /* Type Checking */
    "strict": true,
    "strictPropertyInitialization": false, // 不检查属性是否初始化
    "exactOptionalPropertyTypes": false, // { foo?: T } 会等价于 { foo?: T | undefined }
    "noFallthroughCasesInSwitch": true, // 不允许 case fallthrough
    "noImplicitOverride": true, // 要求显式使用 override modifier
    "noImplicitReturns": true, // 要求显式的 return 语句
    "noPropertyAccessFromIndexSignature": false, // 对于 { [key: string]: T } 要求必须用 obj["foo"] 而不是 obj.foo
    "noUncheckedIndexedAccess": false, // { [key: string]: T } 不会自动变成 { [key: string]: T | undefined }
    "skipLibCheck": true
  }
}

Expected behavior

I try to update "moduleResolution" to 'node16', 'nodenext', or 'bundler',I've encountered many other types of errors, so I hope it can be compatible with my tsconfig.json configuration, similar to version 7.

Code snippets

No response

Repository URL example

No response

OS

macOS

Node version

Node v20.11.1

Library version

v8.3.0

Additional context

No response

@Romakita
Copy link
Collaborator

Romakita commented Dec 9, 2024

@vangie it’s related to your tsconfig. Generated a project, using CLI and compare the diff.

I already migrated two project on v8. It works!

see you

@Romakita
Copy link
Collaborator

Romakita commented Dec 9, 2024

Here is prisma project example on v8:
tsedio/tsed-example-prisma#3

@Romakita Romakita closed this as completed Dec 9, 2024
Copy link

github-actions bot commented Dec 9, 2024

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

@TheRealAstoo
Copy link

Hello @Romakita, do you have an idea of the issue in this tsconfig? I have the same error in my project, while doing the transition to V8, with this tsconfig:

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "esnext",
    "module": "nodenext",
    "sourceMap": true,
    "declaration": false,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "allowImportingTsExtensions": true,
    "moduleResolution": "nodenext",
    "isolatedModules": false,
    "suppressImplicitAnyIndexErrors": false,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": false,
    "useDefineForClassFields": false,
    "noUnusedParameters": false,
    "allowSyntheticDefaultImports": true,
    "importHelpers": true,
    "skipLibCheck": true,
    "newLine": "LF",
    "noEmit": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "lib": ["es7", "dom", "ESNext.AsyncIterable"],
    "typeRoots": ["./node_modules/@types"]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": ["node_modules", "./public", "dist", "tests"],
  "linterOptions": {
    "exclude": []
  },
}

PS: I'm having a look on the repo you talked about.

@Romakita
Copy link
Collaborator

@TheRealAstoo Have you checkout the project example, then installed it, then compiled (or started the project).

Try to apply this tsconfig on your project and isolate the correct configuration:
https://github.com/tsedio/tsed-example-prisma/blob/master/tsconfig.base.json

@Romakita
Copy link
Collaborator

Check also your typescript version :)

@TheRealAstoo
Copy link

@TheRealAstoo Have you checkout the project example, then installed it, then compiled (or started the project).

Try to apply this tsconfig on your project and isolate the correct configuration: https://github.com/tsedio/tsed-example-prisma/blob/master/tsconfig.base.json

Check also your typescript version :)

I will, thank you for the answer :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants