From e297d2677fb7bb82e6c06ef4a34532c8d65bcb0b Mon Sep 17 00:00:00 2001 From: york yao Date: Thu, 26 Jan 2017 19:20:44 +0800 Subject: [PATCH] fix name, class to interface, var to const, enable strictNullChecks --- node-zookeeper-client/index.d.ts | 6 +++--- .../node-zookeeper-client-tests.ts | 14 +++++++------- node-zookeeper-client/tsconfig.json | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/node-zookeeper-client/index.d.ts b/node-zookeeper-client/index.d.ts index cb9979e9f4..a85d14b7cc 100644 --- a/node-zookeeper-client/index.d.ts +++ b/node-zookeeper-client/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Jasmine 2.5 +// Type definitions for node-zookeeper-client 0.2 // Project: https://github.com/alexguan/node-zookeeper-client // Definitions by: York Yao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -72,7 +72,7 @@ export class Event { getPath(): string; } -export class Transaction { +interface Transaction { create(path: string, dataOrAclsOrmode1?: Buffer | ACL[] | number, dataOrAclsOrmode2?: Buffer | ACL[] | number, dataOrAclsOrmode3?: Buffer | ACL[] | number): this; setData(path: string, data: Buffer | null, version?: number): this; check(path: string, version?: number): this; @@ -80,7 +80,7 @@ export class Transaction { commit(callback: (error: Error | Exception, results: any) => void): void; } -export class Client extends EventEmitter { +interface Client extends EventEmitter { connect(): void; close(): void; create(path: string, callback: (error: Error | Exception, path: string) => void): void; diff --git a/node-zookeeper-client/node-zookeeper-client-tests.ts b/node-zookeeper-client/node-zookeeper-client-tests.ts index 19cca8628b..91c434bafa 100644 --- a/node-zookeeper-client/node-zookeeper-client-tests.ts +++ b/node-zookeeper-client/node-zookeeper-client-tests.ts @@ -1,8 +1,8 @@ import * as zookeeper from "node-zookeeper-client"; { - var client = zookeeper.createClient('localhost:2181'); - var path = process.argv[2]; + const client = zookeeper.createClient('localhost:2181'); + const path = process.argv[2]; client.once('connected', function () { console.log('Connected to the server.'); @@ -44,8 +44,8 @@ function listChildren(client: zookeeper.Client, path: string) { } { - var client = zookeeper.createClient('localhost:2181'); - var path = process.argv[2]; + const client = zookeeper.createClient('localhost:2181'); + const path = process.argv[2]; client.once('connected', function () { console.log('Connected to ZooKeeper.'); @@ -55,7 +55,7 @@ function listChildren(client: zookeeper.Client, path: string) { client.connect(); } -var client = zookeeper.createClient( +const client = zookeeper.createClient( 'localhost:2181/test', { sessionTimeout: 10000 } ); @@ -188,12 +188,12 @@ var client = zookeeper.createClient( } { - var state = client.getState(); + const state = client.getState(); console.log('Current state is: %s', state); } { - var id = client.getSessionId(); + const id = client.getSessionId(); console.log('Session id is: %s', id.toString('hex')); } diff --git a/node-zookeeper-client/tsconfig.json b/node-zookeeper-client/tsconfig.json index d93291d45b..1f5ffdedf8 100644 --- a/node-zookeeper-client/tsconfig.json +++ b/node-zookeeper-client/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../"