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
merged 3 commits into from Jul 29, 2019

Conversation

murgatroid99
Copy link
Member

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.

@@ -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
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@murgatroid99 murgatroid99 merged commit 716b29f into grpc:master Jul 29, 2019
@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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants