tsoa icon indicating copy to clipboard operation
tsoa copied to clipboard

Unable to resolve Return types from different files.

Open Enquier opened this issue 1 year ago • 5 comments

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 ]

Enquier avatar Dec 20 '24 19:12 Enquier

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.👀

github-actions[bot] avatar Dec 20 '24 19:12 github-actions[bot]

Similar to the closed (stale) issue #1653 ?

Enquier avatar Dec 20 '24 19:12 Enquier

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 avatar Dec 20 '24 19:12 Enquier

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

Enquier avatar Dec 20 '24 19:12 Enquier

what compile option you add ?

ThalysSilva avatar Feb 07 '25 03:02 ThalysSilva

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

github-actions[bot] avatar Jul 08 '25 00:07 github-actions[bot]