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

Can't call methods from @Inject class using typescript-io. #1529

Closed
2 of 4 tasks
hs-wolf opened this issue Dec 30, 2023 · 1 comment
Closed
2 of 4 tasks

Can't call methods from @Inject class using typescript-io. #1529

hs-wolf opened this issue Dec 30, 2023 · 1 comment

Comments

@hs-wolf
Copy link

hs-wolf commented Dec 30, 2023

Hi, I have a very simple project setup, with Nx as mono repo solution and a barebones Express app.

The app has 1 controller and 1 service, I tried following Tsoa's official guide on how to implement typescript-ioc: https://tsoa-community.github.io/docs/di.html#typescript-ioc

Even though the routes and app are being built, and the app is being served correctly, I get an error when calling methods from an injected class.

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

I should be able to call methods from a class using the @Inject decorator.

My base tsconfig.ts file has the decorator properties set.

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
  }
}

Current Behavior

When calling a method from a class using the @Inject decorator I get the error bellow. It's not very informative and I couldn't find a similar error that matched my case.

TypeError: Invalid type requested to IoC container. Type is not defined.

Possible Solution

Maybe a configuration or package/package version that I'm missing?

Steps to Reproduce

  1. Clone repo.
    git clone --single-branch --branch template-name https://github.com/hs-wolf/nx-monorepo-templates.git
  2. Install pnpm
    npm install -g pnpm
  3. Install packages
    pnpm install
  4. Run Express App
    npx nx run express-api:serve:development
  5. Open http://localhost:3000/docs/
  6. Find the users/{userId} endpoint, open It and try any number as the Id to call the service.
  7. Back to VSCode terminal to see the error.

Context (Environment)

Version of the library:

"@tsoa/runtime": "^5.0.0"
"tsoa": "^5.1.1"

Version of NodeJS: v18.19.0

  • Confirm you were using yarn not npm: []
  • Confirm you were using pnpm not npm: [X]
Copy link

Hello there hs-wolf 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

@hs-wolf hs-wolf closed this as completed Jan 2, 2024
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

No branches or pull requests

1 participant