Broken typings when upgrading to 21.4.0
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- node.js, typescript
Línea de trabajo
Comienza reproduciendo el ejemplo de TypeScript con node.js 22.15.1 y compara las definiciones de tipos de Request y RouteOptions entre las versiones 21.3.12 y 21.4.0. Rastrea la incompatibilidad relacionada con route.settings.pre y los tipos de payload genéricos. Se considera terminado cuando una someFunction compartida puede aceptar requests de handlers con distintos payloads sin el error TS2345 indicado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Runtime
node.js
Runtime version
22.15.1
Module version
21.4.0
Last module version without issue
21.3.12
Used with
No response
Any other relevant information
No response
What are you trying to achieve or the steps to reproduce?
We have handle who look simplified like this:
export const create = ():RouteOptions => ({
handler: async (req: Request<{ Payload: { from: string; to: string; } }>, h: ResponseToolkit): Promise<ResponseObject> => {
const from = req.payload.from
const to = req.payload.to
.....
await someFunction(req);
return h.response().code(201);
},
});
export const someFunction = async (request: Request): Promise<void> => ({
.....
})
What was the result you got?
I get a typescript error:
error TS2345: Argument of type 'Request<{ Payload: { from: string; to: string; }; }>' is not assignable to parameter of type 'Request<ReqRefDefaults>'.
The types of 'route.settings.pre' are incompatible between these types.
Type 'RouteOptionsPreArray<{ Payload: { from: string; to: string; }; }> | undefined' is not assignable to type 'RouteOptionsPreArray<ReqRefDefaults> | undefined'.
Type 'RouteOptionsPreArray<{ Payload: { from: string; to: string; }; }>' is not assignable to type 'RouteOptionsPreAllOptions<ReqRefDefaults>[]'.
Type 'RouteOptionsPreAllOptions<{ Payload: { from: string; to: string; }; }>' is not assignable to type 'RouteOptionsPreAllOptions<ReqRefDefaults>'.
Type 'Method<{ Payload: { from: string; to: string; }; }, ReturnValue<{ Payload: { from: string; to: string; }; }>>' is not assignable to type 'RouteOptionsPreAllOptions<ReqRefDefaults>'.
Type 'Method<{ Payload: { from: string; to: string; }; }, ReturnValue<{ Payload: { from: string; to: string; }; }>>' is not assignable to type 'Method<ReqRefDefaults, ReturnValue<ReqRefDefaults>>'.
Types of parameters 'request' and 'request' are incompatible.
Type 'Request<ReqRefDefaults>' is not assignable to type 'Request<{ Payload: { from: string; to: string; }; }>'.
Types of property 'payload' are incompatible.
Type 'string | object | Readable | Buffer<ArrayBufferLike>' is not assignable to type '{ from: string; to: string; }'.
Type 'string' is not assignable to type '{ from: string; to: string; }'.
To fix this problem I need to change:
export const someFunction = async (request: Request<{ Payload: { from: string; to: string; } }>): Promise<void> => ({
.....
})
but this does not work out if someFunction is used by different handler with different payloads.
What result did you expect?
keep it the way as in 21.3.12 an not have an error here.
- Lenguaje dominante
- JavaScript
- Estrellas
- 14.8k
- Forks
- 1.4k
- Merge medio
- 17 min
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de hapijs/hapi
-
The data property of a Boom error gets mangled when the error comes from a validatorQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
-
The `abort` event on nodejs is deprecatedQuizá libre de nuevo @akashbirajdar04 la tomó hace 176 días y no hay ningún pull request abierto. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
-
Error-tracking software doesn't catch hapi application errors if an incoming request gets prematurely closedQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Use ECMA Decorators for routingAbiertofeature
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Todos los issues de hapijs/hapi
Issues similares
-
accessibility bug html websites
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
quarto-dev/quarto-cli#15187 ·
Los mantenedores suelen responder en 1 día
-
bug needs triage P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
pbakaus/impeccable#1143 ·
Los mantenedores suelen responder en 1 día
-
status: waiting for maintainer
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
mui/material-ui#49547 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
capricorn86/happy-dom#2544 ·
Los mantenedores suelen responder en 1 día
-
next() is called twice when the request closes after busboy fails to startPosiblemente ocupada @NgoQuocViet2001 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100