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

Unable to resolve Return types from different files. #1735

Open
1 task
Enquier opened this issue Dec 20, 2024 · 4 comments
Open
1 task

Unable to resolve Return types from different files. #1735

Enquier opened this issue Dec 20, 2024 · 4 comments

Comments

@Enquier
Copy link

Enquier commented Dec 20, 2024

Sorting

  • I'm submitting a ...

    • [ X] bug report
    • feature request
    • [X ] support request
  • I confirm that I

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

Expected Behavior

I have a controller which returns a type that is defined in another file, however TSOA fails to find it during generation. Not sure if this is a relative path issue?

Current Behavior

import { IType } from 'folder/file';

@Post('{path}')
createOrUpdateType(@Path() path
    ): Promise<IElementsResponse> {
...stufff
}

Possible Solution

Steps to Reproduce

run tsoa spec-and-routes with some thing similar to above:

Generate routes error.
 GenerateMetadataError: No declarations found for referenced type IElementsResponse.
    at TypeResolver.getModelTypeDeclarations (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:871:62)
    at TypeResolver.calcRefTypeName (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:536:39)
    at TypeResolver.calcTypeReferenceTypeName (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:712:34)
    at TypeResolver.getReferenceType (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:721:35)
    at TypeResolver.resolveTypeReferenceNode (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:468:21)
    at TypeResolver.resolve (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:293:21)
    at TypeResolver.resolveTypeReferenceNode (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:458:93)
    at TypeResolver.resolve (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\typeResolver.js:293:21)
    at MethodGenerator.Generate (C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\methodGenerator.js:62:78)
    at C:\Users\119481\git\ddp-api-server\node_modules\@tsoa\cli\dist\metadataGeneration\controllerGenerator.js:46:41

Context (Environment)

Version of the library: "^6.5.1"
Version of NodeJS: "22.x"

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

Hello there Enquier 👋

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

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

@Enquier
Copy link
Author

Enquier commented Dec 20, 2024

Similar to the closed (stale) issue #1653 ?

@Enquier
Copy link
Author

Enquier commented Dec 20, 2024

I did a little more testing and it seems as though if I put in a full relative path it works: "eg ../../path/to/file as opposed to path/to/file.
Is there a config I am missing or is this just a limitation of the tool

@Enquier
Copy link
Author

Enquier commented Dec 20, 2024

Added some config to compiler options... didn't realize TSOA wasn't taking from the local tsconfig (my bad)

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