tsoa: TS type aliases are not supported
Here is an example:
import { Controller, Get, Route } from 'tsoa';
export type Foo = number | string | Date;
@Route('test')
export class Test extends Controller {
@Get('test1')
public async getTest1(): Promise<Foo> {
return 8;
}
}
Running tsoa routes
throws a TypeError:
enerate routes error.
TypeError: Cannot read property 'text' of undefined
at /Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/resolveType.js:260:79
at Array.map (<anonymous>)
at getLiteralType (/Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/resolveType.js:260:27)
at resolveType (/Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/resolveType.js:85:23)
at Object.resolveType (/Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/resolveType.js:73:20)
at MethodGenerator.Generate (/Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/methodGenerator.js:30:34)
at /Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/controllerGenerator.js:38:58
at Array.map (<anonymous>)
at ControllerGenerator.buildMethods (/Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/controllerGenerator.js:38:14)
at ControllerGenerator.Generate (/Users/eryk/work/unito/dev/connectors/node_modules/tsoa/dist/metadataGeneration/controllerGenerator.js:27:27)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 15 (1 by maintainers)
I am getting the exact same thing as @JakeStoeffler, any plan on supporting custom types for defining path params?
@lukeautry
I also can’t do simple things like:
and then use it as a path param (trying to have my controller be db-agnostic):
This gives the following error when running
tsoa routes
:@erykwarren @simllll @fbarbare @Esya @Superd22 @JakeStoeffler @ronjouch @james-ingold, @bgsandan, @WretchedDade, @AlexChambers, @HarryGogonis @adikaladik @AlexChambers – We’re super excited to share that we have a beta release of the type alias feature available and we’d love you to try it so we can consider releasing it to everyone. It’s simple to do. All you have to do is install it with the tag. So like this:
or
Please let us know in this thread if you like it or if you find any bugs and we can cut the
latest
release so that everyone can get this awesome feature. 😃Thanks goes out to @WoH for his incredible work on this contribution. 🎉 🎈 🥇
Hi @dgreene1. Hope you’re welcoming some feedback on this issue 😃 I’ve tried testing the V3 beta but I am still getting the same error as in the example given by Jake above (ie path param has custom type). Not sure if this issue attempted to solve exactly this use case or if it was specific to return types, or I’m being a noob and doing something completely wrong.
export class IotService extends Controller { @Get(‘iot/templates’) public async allTemplates(token: ApigeeToken, @Query() query: string): Promise<IotTemplate[]> { blah blah } Error: @Path(‘token’) Can’t support ‘refObject’ type.
Cheers, Dave