Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve server-related types exported by grpc-js #972

merged 3 commits into from Jul 29, 2019


Copy link

@murgatroid99 murgatroid99 commented Jul 16, 2019

This mainly makes the server call types and Server#registerService function signature more specific, the server error types more permissive, and exports some more types needed for writing service implementations.

Also, this fixes a typo in the native library's index.d.ts that got brought up in #965. That class is essentially internal, so code written using the typo works. I have added an alias to avoid breaking that.

@murgatroid99 murgatroid99 requested a review from nicolasnoble Jul 16, 2019
@@ -18,13 +18,14 @@
import { EventEmitter } from 'events';
import * as http2 from 'http2';
import { Duplex, Readable, Writable } from 'stream';
import * as util from 'util';
Copy link

@cjihrig cjihrig Jul 17, 2019

util.isNumber() and util.isString() are deprecated in favor of typeof value === 'number' and typeof value === 'string', respectively.

? error.metadata
: new Metadata(),

if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
if ('code' in error && util.isNumber(error.code) && Number.isInteger(error.code)) {
Copy link

@cjihrig cjihrig Jul 17, 2019

The util.isNumber() (or typeof error.code === 'number') check shouldn't be necessary due to the Number.isInteger() call.

Copy link
Member Author

@murgatroid99 murgatroid99 Jul 29, 2019

I think Typescript was not happy with calling Number.isInteger on that value without verifying that it was a number.

Copy link

@cjihrig cjihrig Jul 29, 2019

I think you're right: microsoft/TypeScript#21199 😕

@murgatroid99 murgatroid99 merged commit 716b29f into grpc:master Jul 29, 2019
17 of 19 checks passed
@lock lock bot locked as resolved and limited conversation to collaborators Oct 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants