From e3c3c3462f98d6e7903e2f282de184609f33ca44 Mon Sep 17 00:00:00 2001 From: Kelvin Jin Date: Wed, 31 Jan 2018 14:28:39 -0800 Subject: [PATCH] Fix TS compiler errors and pin TS to 2.7 --- package.json | 2 +- packages/grpc-js-core/package.json | 2 +- packages/grpc-js-core/src/channel.ts | 4 ++-- packages/grpc-js-core/test/test-call-stream.ts | 10 +++++----- packages/grpc-js-core/test/test-channel-credentials.ts | 2 +- packages/grpc-js/package.json | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index cb324a08..5310e7f5 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "through2": "^2.0.3", "ts-node": "^3.3.0", "tslint": "^5.5.0", - "typescript": "^2.5.1", + "typescript": "~2.7.0", "xml2js": "^0.4.19" }, "contributors": [ diff --git a/packages/grpc-js-core/package.json b/packages/grpc-js-core/package.json index d5fdd46c..e0d48bd4 100644 --- a/packages/grpc-js-core/package.json +++ b/packages/grpc-js-core/package.json @@ -19,7 +19,7 @@ "@types/node": "^8.0.55", "clang-format": "^1.0.55", "gts": "^0.5.1", - "typescript": "^2.6.1" + "typescript": "~2.7.0" }, "contributors": [ { diff --git a/packages/grpc-js-core/src/channel.ts b/packages/grpc-js-core/src/channel.ts index 35ca6f6c..51ec1fa5 100644 --- a/packages/grpc-js-core/src/channel.ts +++ b/packages/grpc-js-core/src/channel.ts @@ -76,7 +76,7 @@ export class Http2Channel extends EventEmitter implements Channel { private connectivityState: ConnectivityState = ConnectivityState.IDLE; /* For now, we have up to one subchannel, which will exist as long as we are * connecting or trying to connect */ - private subChannel: http2.ClientHttp2Session|null; + private subChannel: http2.ClientHttp2Session|null = null; private filterStackFactory: FilterStackFactory; private subChannelConnectCallback: ()=>void = () => {}; @@ -123,7 +123,7 @@ export class Http2Channel extends EventEmitter implements Channel { } // Transition from any of a set of oldStates to a specific newState - private transitionToState(oldStates: [ConnectivityState], newState: ConnectivityState): void { + private transitionToState(oldStates: ConnectivityState[], newState: ConnectivityState): void { if (oldStates.indexOf(this.connectivityState) > -1) { let oldState: ConnectivityState = this.connectivityState; this.connectivityState = newState; diff --git a/packages/grpc-js-core/test/test-call-stream.ts b/packages/grpc-js-core/test/test-call-stream.ts index e7126d62..91d694dc 100644 --- a/packages/grpc-js-core/test/test-call-stream.ts +++ b/packages/grpc-js-core/test/test-call-stream.ts @@ -38,11 +38,11 @@ class ClientHttp2StreamMock extends stream.Duplex implements http2.ClientHttp2St } bytesRead = 0; dataFrame = 0; - aborted: boolean; - destroyed: boolean; - rstCode: number; - session: http2.Http2Session; - state: http2.StreamState; + aborted: boolean = false; + destroyed: boolean = false; + rstCode: number = 0; + session: http2.Http2Session = {} as any; + state: http2.StreamState = {} as any; priority = mockFunction; rstStream = mockFunction; rstWithNoError = mockFunction; diff --git a/packages/grpc-js-core/test/test-channel-credentials.ts b/packages/grpc-js-core/test/test-channel-credentials.ts index fac88110..15dfbfac 100644 --- a/packages/grpc-js-core/test/test-channel-credentials.ts +++ b/packages/grpc-js-core/test/test-channel-credentials.ts @@ -8,7 +8,7 @@ import {ChannelCredentials} from '../src/channel-credentials'; import {assert2, mockFunction} from './common'; class CallCredentialsMock implements CallCredentials { - child: CallCredentialsMock; + child: CallCredentialsMock|null = null; constructor(child?: CallCredentialsMock) { if (child) { this.child = child; diff --git a/packages/grpc-js/package.json b/packages/grpc-js/package.json index 1dbddbb0..8486c043 100644 --- a/packages/grpc-js/package.json +++ b/packages/grpc-js/package.json @@ -29,6 +29,6 @@ }, "devDependencies": { "gts": "^0.5.1", - "typescript": "^2.6.1" + "typescript": "~2.7.0" } }