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
There is nothing wrong with these definitions and they are very useful. However, exporting a class implies that I must be able to extend them, e.g. the following must work (and indeed compiles fine in Typescript):
However, running this code throws an TypeError: Class extends value undefined is not a constructor or null because index.js of grpc-web does not actually export the RpcError class (or the UnaryResponse class for that matter). I confirmed this by checking grpc-web/packages/grpc-web/exports.js where only GrpcWebClientBase, StatusCode, MethodDescriptor and MethodType are exported by grpc-web.
Suggested fix:
Either change the index.d.ts to reflect that some classes are not exported or change exports.js to also export the classes that are exported in index.d.ts. I prefer the latter as that makes grpc-web more extendable.
If you think this is a good idea, I can create a merge-request for it in the coming week.
The text was updated successfully, but these errors were encountered:
(and I've mistaken the author for you actually until you mentioned.. 😂)
Note that the PR isn't adding all missing classes as you've suggested. But maybe it's added enough of the common ones to be sufficient for most? Please feel free to comment on the PR if you have other thoughts.. :)
A relatively simple issue but I think quite important:
The
index.d.ts
contains definitions like the following (grpc-web = 1.3.0):There is nothing wrong with these definitions and they are very useful. However,
export
ing a class implies that I must be able to extend them, e.g. the following must work (and indeed compiles fine in Typescript):However, running this code throws an
TypeError: Class extends value undefined is not a constructor or null
becauseindex.js
ofgrpc-web
does not actually export theRpcError
class (or theUnaryResponse
class for that matter). I confirmed this by checkinggrpc-web/packages/grpc-web/exports.js
where onlyGrpcWebClientBase
,StatusCode
,MethodDescriptor
andMethodType
are exported bygrpc-web
.Suggested fix:
Either change the
index.d.ts
to reflect that some classes are not exported or changeexports.js
to also export the classes that are exported inindex.d.ts
. I prefer the latter as that makesgrpc-web
more extendable.If you think this is a good idea, I can create a merge-request for it in the coming week.
The text was updated successfully, but these errors were encountered: