You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typescript incompatible type in 3.1.0 and Express 4.x #340
(property) IncomingMessage.headers: IncomingHttpHeaders
Argument of type 'IncomingHttpHeaders' is not assignable to parameter of type 'Headers'.
Index signatures are incompatible.
Type 'string | string[]' is not assignable to type 'string'.
Type 'string[]' is not assignable to type 'string'.ts(2345)
It appears that the IncomingHttpHeaders type is from Node core, so I think this will probably be a common issue. We should consider modifying our type.
Trying what you suggested (req.headers as Headers):
Argument of type 'Headers' is not assignable to parameter of type 'import("c:/Users/adam_a/repos/Segment-Webhook/node_modules/cloudevents/dist/transport/http/headers").Headers'.
Index signature is missing in type 'Headers'.ts(2345)
Conversion of type 'IncomingHttpHeaders' to type 'Headers' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352)
Conversion of type 'IncomingHttpHeaders' to type 'Headers' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'IncomingHttpHeaders' is missing the following properties from type 'Headers': append, delete, get, has, and 6 more.ts(2352)
Activity
lance commentedon Sep 8, 2020
It appears that the
IncomingHttpHeaderstype is from Node core, so I think this will probably be a common issue. We should consider modifying our type.sdk-javascript/src/message/index.ts
Lines 21 to 23 in 1fa3a05
In the meantime @aabrams can you try
aabrams commentedon Sep 9, 2020
Trying what you suggested (req.headers as Headers):
Argument of type 'Headers' is not assignable to parameter of type 'import("c:/Users/adam_a/repos/Segment-Webhook/node_modules/cloudevents/dist/transport/http/headers").Headers'.
Index signature is missing in type 'Headers'.ts(2345)
Conversion of type 'IncomingHttpHeaders' to type 'Headers' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352)
Conversion of type 'IncomingHttpHeaders' to type 'Headers' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'IncomingHttpHeaders' is missing the following properties from type 'Headers': append, delete, get, has, and 6 more.ts(2352)
fix: extend Node.js IncomingHttpHeaders in our Headers type