-
Notifications
You must be signed in to change notification settings - Fork 475
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
After update 6.1.5 Types of property 'successStatus' are incompatible #1594
Comments
@cesco69 successStatus should allow pass w/ undefined in design. |
@jackey8616 Since ts is also breaking stuff in between minors in the name of 'well that was broken before anyway', unless we used to handle this before properly, this could be ok as a fix. |
Not sure what cause this, some of test cases does covered the situation that give a undefined value at successStatus. |
This can help? export interface ProjectsResponse {
id: number;
name: string;
state: string;
active_users_count?: number;
update_date: string;
external_data: string;
has_shared: boolean;
codice: string;
subject: string;
logo: string;
start_date: string;
end_date: string;
tagbim: string;
latitudine: string;
longitudine: string;
preferito: number;
is_system: boolean;
is_default: boolean;
application: string;
creation_date: string;
state_values_enabled: boolean;
usage: number;
owner_name?: string;
owner_surname?: string;
owner_avatar?: string;
owner_id?: number;
owner_email?: string;
owner_state?: string;
subscription_id?: number;
subscription_type?: string;
owner_subscription_name?: string;
owner_subscription_surname?: string;
owner_subscription_avatar?: string;
owner_subscription_id?: number;
owner_subscription_email?: string;
owner_subscription_state?: string;
info_state: Array<{ state: number; message: string }>;
space_gb: number;
}
@Route()
@Security({ serviceKey: [], accessToken: [] })
@Middlewares(myMiddleware)
export class ProjectsController extends Controller {
@Get('/projects')
public async getProjects(
@Request() req: express.Request,
@Query('start') start: number = -1,
@Query('size') size: number = -1,
@Query('filter') filter?: string,
@Query('infoowner') infoowner: 0 | 1 = 1,
@Query('infosubscription') infosubscription: 0 | 1 = 1,
@Query('userscount') userscount: 0 | 1 = 1,
@Query('public') publicc: 0 | 1 = 0,
@Query('platform') platform: 0 | 1 = 0,
@Query('shared') shared: 0 | 1 = 1,
@Query('order') order: 0 | 1 = 1
): Promise<{ projects: Array<ProjectsResponse> }> {
return { projects: [] }
}
} |
@cesco69 Also need the routes.ts please. |
@jackey8616 all the file or just this: // ###########################################################################################################
// NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
// ###########################################################################################################
app.get('/projects',
authenticateMiddleware([{"serviceKey":[],"accessToken":[]}]),
...(fetchMiddlewares<RequestHandler>(ProjectsController)),
...(fetchMiddlewares<RequestHandler>(ProjectsController.prototype.getProjects)),
function ProjectsController_getProjects(request: ExRequest, response: ExResponse, next: any) {
const args: Record<string, TsoaRoute.ParameterSchema> = {
req: {"in":"request","name":"req","required":true,"dataType":"object"},
start: {"default":-1,"in":"query","name":"start","dataType":"double"},
size: {"default":-1,"in":"query","name":"size","dataType":"double"},
filter: {"in":"query","name":"filter","dataType":"string"},
infoowner: {"default":1,"in":"query","name":"infoowner","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
infosubscription: {"default":1,"in":"query","name":"infosubscription","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
userscount: {"default":1,"in":"query","name":"userscount","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
publicc: {"default":0,"in":"query","name":"public","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
platform: {"default":0,"in":"query","name":"platform","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
shared: {"default":1,"in":"query","name":"shared","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
order: {"default":1,"in":"query","name":"order","dataType":"union","subSchemas":[{"dataType":"enum","enums":[0]},{"dataType":"enum","enums":[1]}]},
};
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
let validatedArgs: any[] = [];
try {
validatedArgs = templateService.getValidatedArgs({ args, request, response });
const controller = new ProjectsController();
templateService.apiHandler({
methodName: 'getProjects',
controller,
response,
next,
validatedArgs,
successStatus: undefined,
});
} catch (err) {
return next(err);
}
}); |
side note... I have an aggressive (all strict check enabled) tsconfig setup: {
"compilerOptions": {
"lib": [
"es2023"
],
"target": "es2022",
"module": "node16",
"moduleResolution": "node16",
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"importHelpers": true,
"alwaysStrict": true,
"strict": true,
"useUnknownInCatchVariables": true,
"strictFunctionTypes": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"exactOptionalPropertyTypes": true,
"noImplicitOverride": true,
"allowJs": true,
"sourceMap": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noUncheckedIndexedAccess": true,
"isolatedModules": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictBindCallApply": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noPropertyAccessFromIndexSignature": false,
"declaration": true,
"outDir": "dist",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
],
"typeRoots": [
"node_modules/@types"
],
"types": [
"node",
"express"
]
} |
@jackey8616 with my tsconfig the correct type ExpressApiHandlerParameters = {
methodName: string;
controller: Controller | Object;
response: ExResponse;
next: ExNext;
validatedArgs: any[];
successStatus?: number | undefined;
}; |
@jackey8616 mhh yep.. in both case, this PR #1595 fix the problem |
with the tsconfig |
IMO, |
@jackey8616 declare module '@tsoa/runtime' {
type ExpressApiHandlerParameters = {
methodName: string;
// eslint-disable-next-line @typescript-eslint/ban-types
controller: Controller | Object;
response: ExResponse;
next: ExNext;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
validatedArgs: any[];
successStatus?: number | undefined;
};
interface ExpressTemplateService extends TemplateService<ExpressApiHandlerParameters, ExpressValidationArgsParameters, ExpressReturnHandlerParameters> {
apiHandler(params: ExpressApiHandlerParameters);
}
} The only fix for support |
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 |
Any news @jackey8616 ? |
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 |
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
After update from
to
running
I have this error:
dist/routes.ts(880,42)
Context (Environment)
Version of the library: 6.1.5
Version of NodeJS: 20
Breaking change?
Yes, same code works with 6.0.0
The text was updated successfully, but these errors were encountered: