types: add string[] to routeOptions.method#5762
Conversation
climba03003
left a comment
There was a problem hiding this comment.
Please add an unit test for the types change.
|
@climba03003 Is anything else needed from me here to get this merged? |
|
You could actually improve the developer experience significantly. add following type to utility.d.ts, see like nodejs/undici#3479 type AutocompletePrimitiveBaseType<T> =
T extends string ? string :
T extends number ? number :
T extends boolean ? boolean :
never;
export type Autocomplete<T> = T | (AutocompletePrimitiveBaseType<T> & Record<never, never>);Also export _HTTPMethods in utility.d.ts In request.d.ts modify you change by changing the type of method Cross check if at runtime the HTTPMethod is actually uppercased if a lowercase value is provided. |
Nice, but I'm just trying to fix the type error for now as it poses a runtime risk. Feel free to open a PR for the autocomplete 👍 |
|
There is no runtime risk?! |
The test case in the PR description highlights the runtime risk I'm trying to fix. If, for example you were to call |
|
You would have a runtime risk, if you would not use typescript anyway. |
Sorry, I'm not sure I follow |
|
added a follow up pr #5766 |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The type for
routeOptions.methodis incorrect and may cause runtime errors if assumed to be a string.Checklist
npm run test:typescriptand the Code of conduct