Broken typings when upgrading to 21.4.0
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Inizia riproducendo l’esempio TypeScript con node.js 22.15.1 e confronta le definizioni dei tipi di Request e RouteOptions tra le versioni 21.3.12 e 21.4.0. Traccia l’incompatibilità che coinvolge route.settings.pre e i tipi di payload generici. Il lavoro è completato quando una someFunction condivisa può accettare requests provenienti da handlers con payload diversi senza l’errore TS2345 segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 14.8k
- Fork
- 1.4k
- Merge medio
- 17m
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hapijs/hapi
-
The data property of a Boom error gets mangled when the error comes from a validatorForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
-
The `abort` event on nodejs is deprecatedForse di nuovo libera @akashbirajdar04 l’ha presa 176 giorni fa e non c’è nessuna pull request aperta. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
Error-tracking software doesn't catch hapi application errors if an incoming request gets prematurely closedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Issue simili
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Update to mocha 12.xAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rescript-lang/rescript#8996 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Ministerstvoidey.ruApertacheck:passed logos:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100