diff --git a/package.json b/package.json index d91ac708c..4859b3918 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^2.3.0", + "@types/extend": "^3.0.0", "@types/mocha": "^5.2.5", "async": "^2.6.1", "binary-search-bounds": "^2.0.4", diff --git a/test/batch-transaction.js b/test/batch-transaction.ts similarity index 97% rename from test/batch-transaction.js rename to test/batch-transaction.ts index 3e499b452..4291cdff1 100644 --- a/test/batch-transaction.js +++ b/test/batch-transaction.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {util} = require('@google-cloud/common-grpc'); @@ -31,23 +31,27 @@ const fakePfy = extend({}, pfy, { }, }); -const fakeCodec = { +const fakeCodec: any = { encode: util.noop, Int: function() {}, Float: function() {}, SpannerDate: function() {}, }; -function FakeTransaction(session) { - this.calledWith_ = arguments; - this.session = session; +class FakeTransaction { + calledWith_: IArguments; + session; + constructor(session) { + this.calledWith_ = arguments; + this.session = session; + } } describe('BatchTransaction', () => { let BatchTransaction; let batchTransaction; - const SESSION = {}; + const SESSION: any = {}; before(() => { BatchTransaction = proxyquire('../src/batch-transaction.js', { diff --git a/test/codec.js b/test/codec.ts similarity index 99% rename from test/codec.js rename to test/codec.ts index c9f8f8007..e6615da1e 100644 --- a/test/codec.js +++ b/test/codec.ts @@ -16,12 +16,12 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {util} = require('@google-cloud/common-grpc'); -function FakeGrpcService() {} +const FakeGrpcService: any = class {}; describe('codec', () => { let codecCached; @@ -341,7 +341,7 @@ describe('codec', () => { }, }); - assert.deepStrictEqual(decoded, Buffer.from(value, 'base64')); + assert.deepStrictEqual(decoded, Buffer.from(value as any, 'base64')); }); it('should decode FLOAT64', () => { diff --git a/test/database.js b/test/database.ts similarity index 97% rename from test/database.js rename to test/database.ts index d8b4c0229..a932d9178 100644 --- a/test/database.js +++ b/test/database.ts @@ -16,10 +16,10 @@ 'use strict'; -const assert = require('assert'); -const events = require('events'); -const extend = require('extend'); -const nodeutil = require('util'); +import * as assert from 'assert'; +import {EventEmitter} from 'events'; +import * as extend from 'extend'; +import { ApiError } from '@google-cloud/common'; const proxyquire = require('proxyquire'); const through = require('through2'); const {util} = require('@google-cloud/common-grpc'); @@ -43,40 +43,59 @@ const fakePfy = extend({}, pfy, { }, }); -function FakeBatchTransaction() { - this.calledWith_ = arguments; +class FakeBatchTransaction { + calledWith_: IArguments; + constructor() { + this.calledWith_ = arguments; + } } -function FakeGrpcServiceObject() { - this.calledWith_ = arguments; - events.EventEmitter.call(this); +class FakeGrpcServiceObject extends EventEmitter { + calledWith_: IArguments; + constructor() { + super(); + this.calledWith_ = arguments; + } } -nodeutil.inherits(FakeGrpcServiceObject, events.EventEmitter); -function FakePartialResultStream() { - this.calledWith_ = arguments; +class FakePartialResultStream { + calledWith_: IArguments; + constructor() { + this.calledWith_ = arguments; + } } -function FakeSession() { - this.calledWith_ = arguments; +class FakeSession { + calledWith_: IArguments; + constructor() { + this.calledWith_ = arguments; + } } -function FakeSessionPool() { - this.calledWith_ = arguments; - events.EventEmitter.call(this); +class FakeSessionPool extends EventEmitter { + calledWith_: IArguments; + constructor() { + super(); + this.calledWith_ = arguments; + } + open(){} } -nodeutil.inherits(FakeSessionPool, events.EventEmitter); -FakeSessionPool.prototype.open = util.noop; -function FakeTable() { - this.calledWith_ = arguments; +class FakeTable { + calledWith_: IArguments; + constructor() { + this.calledWith_ = arguments; + } } -function FakeTransactionRequest() { - this.calledWith_ = arguments; +class FakeTransactionRequest { + calledWith_: IArguments; + constructor() { + this.calledWith_ = arguments; + } } -const fakeCodec = { +const fakeCodec: any = { encode: util.noop, Int: function() {}, Float: function() {}, @@ -485,7 +504,7 @@ describe('Database', () => { }); it('should decorate the end() method', done => { - const transaction = {}; + const transaction: any = {}; const end = function(callback) { assert.strictEqual(this, transaction); callback(); // done fn @@ -610,7 +629,7 @@ describe('Database', () => { describe('autoCreate', () => { const error = new Error('Error.'); - error.code = 5; + (error as ApiError).code = 5; const OPTIONS = { autoCreate: true, @@ -690,7 +709,7 @@ describe('Database', () => { it('should not auto create without error code 5', done => { const error = new Error('Error.'); - error.code = 'NOT-5'; + (error as any).code = 'NOT-5'; const options = { autoCreate: true, @@ -711,7 +730,7 @@ describe('Database', () => { }); it('should not auto create unless requested', done => { - const error = new Error('Error.'); + const error = new ApiError('Error.'); error.code = 5; database.getMetadata = function(callback) { @@ -851,7 +870,7 @@ describe('Database', () => { formattedName_: 'formatted-name', }; - const POOL = {}; + const POOL: any = {}; beforeEach(() => { CONFIG = { @@ -942,7 +961,7 @@ describe('Database', () => { formattedName_: 'formatted-name', }; - const POOL = {}; + const POOL: any = {}; beforeEach(() => { REQUEST_STREAM = through(); @@ -1248,7 +1267,7 @@ describe('Database', () => { }); it('should pass json, jsonOptions to PartialResultStream', () => { - const query = extend({}, QUERY); + const query: any = extend({}, QUERY); query.json = {}; query.jsonOptions = {}; @@ -1266,7 +1285,7 @@ describe('Database', () => { done(); }; - const query = extend({}, QUERY); + const query: any = extend({}, QUERY); query.json = {}; query.jsonOptions = {}; @@ -1292,7 +1311,7 @@ describe('Database', () => { const OPTIONS = {a: 'a'}; const FORMATTED_OPTIONS = {b: 'b'}; - FakeTransactionRequest.formatTimestampOptions_ = function(options) { + (FakeTransactionRequest as any).formatTimestampOptions_ = function(options) { assert.strictEqual(options, OPTIONS); return FORMATTED_OPTIONS; }; @@ -1700,7 +1719,6 @@ describe('Database', () => { setImmediate(done); return Promise.resolve(); }; - database.getTransaction(OPTIONS, assert.ifError); }); }); diff --git a/test/gapic-v1-database-admin.js b/test/gapic-v1-database-admin.ts similarity index 98% rename from test/gapic-v1-database-admin.js rename to test/gapic-v1-database-admin.ts index 1e139f281..ca9cae8f0 100644 --- a/test/gapic-v1-database-admin.js +++ b/test/gapic-v1-database-admin.ts @@ -14,13 +14,14 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; +import { ApiError } from '@google-cloud/common'; const spannerModule = require('../src'); const FAKE_STATUS_CODE = 1; const error = new Error(); -error.code = FAKE_STATUS_CODE; +(error as ApiError).code = FAKE_STATUS_CODE; describe('DatabaseAdminClient', () => { describe('listDatabases', () => { @@ -689,7 +690,7 @@ describe('DatabaseAdminClient', () => { }); }); -function mockSimpleGrpcMethod(expectedRequest, response, error) { +function mockSimpleGrpcMethod(expectedRequest, response?, error?) { return function(actualRequest, options, callback) { assert.deepStrictEqual(actualRequest, expectedRequest); if (error) { @@ -702,7 +703,7 @@ function mockSimpleGrpcMethod(expectedRequest, response, error) { }; } -function mockLongRunningGrpcMethod(expectedRequest, response, error) { +function mockLongRunningGrpcMethod(expectedRequest, response, error?) { return request => { assert.deepStrictEqual(request, expectedRequest); const mockOperation = { diff --git a/test/gapic-v1-instance-admin.js b/test/gapic-v1-instance-admin.ts similarity index 99% rename from test/gapic-v1-instance-admin.js rename to test/gapic-v1-instance-admin.ts index 6cf096d0f..8e4348716 100644 --- a/test/gapic-v1-instance-admin.js +++ b/test/gapic-v1-instance-admin.ts @@ -14,13 +14,14 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; +import { ApiError } from '@google-cloud/common'; const spannerModule = require('../src'); const FAKE_STATUS_CODE = 1; const error = new Error(); -error.code = FAKE_STATUS_CODE; +(error as ApiError).code = FAKE_STATUS_CODE; describe('InstanceAdminClient', () => { describe('listInstanceConfigs', () => { @@ -736,7 +737,7 @@ describe('InstanceAdminClient', () => { }); }); -function mockSimpleGrpcMethod(expectedRequest, response, error) { +function mockSimpleGrpcMethod(expectedRequest, response?, error?) { return function(actualRequest, options, callback) { assert.deepStrictEqual(actualRequest, expectedRequest); if (error) { @@ -749,7 +750,7 @@ function mockSimpleGrpcMethod(expectedRequest, response, error) { }; } -function mockLongRunningGrpcMethod(expectedRequest, response, error) { +function mockLongRunningGrpcMethod(expectedRequest, response, error?) { return request => { assert.deepStrictEqual(request, expectedRequest); const mockOperation = { diff --git a/test/gapic-v1.js b/test/gapic-v1.ts similarity index 98% rename from test/gapic-v1.js rename to test/gapic-v1.ts index 81b28bc21..0bee11b01 100644 --- a/test/gapic-v1.js +++ b/test/gapic-v1.ts @@ -14,13 +14,14 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; +import { ApiError } from '@google-cloud/common'; const spannerModule = require('../src'); const FAKE_STATUS_CODE = 1; const error = new Error(); -error.code = FAKE_STATUS_CODE; +(error as ApiError).code = FAKE_STATUS_CODE; describe('InstanceAdminClient', () => { describe('listInstanceConfigs', () => { @@ -736,7 +737,7 @@ describe('InstanceAdminClient', () => { }); }); -function mockSimpleGrpcMethod(expectedRequest, response, error) { +function mockSimpleGrpcMethod(expectedRequest, response?, error?) { return function(actualRequest, options, callback) { assert.deepStrictEqual(actualRequest, expectedRequest); if (error) { @@ -749,7 +750,7 @@ function mockSimpleGrpcMethod(expectedRequest, response, error) { }; } -function mockLongRunningGrpcMethod(expectedRequest, response, error) { +function mockLongRunningGrpcMethod(expectedRequest, response?, error?) { return request => { assert.deepStrictEqual(request, expectedRequest); const mockOperation = { diff --git a/test/index.js b/test/index.ts similarity index 98% rename from test/index.js rename to test/index.ts index 2314fe040..8be14d980 100644 --- a/test/index.js +++ b/test/index.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const path = require('path'); const proxyquire = require('proxyquire'); @@ -74,7 +74,7 @@ function fakeGoogleAuth() { }; } -const fakeCodec = { +const fakeCodec: any = { SpannerDate: util.noop, }; @@ -307,15 +307,15 @@ describe('Spanner', () => { let formatName_; before(() => { - formatName_ = FakeInstance.formatName_; + formatName_ = (FakeInstance as any).formatName_; }); after(() => { - FakeInstance.formatName_ = formatName_; + (FakeInstance as any).formatName_ = formatName_; }); beforeEach(() => { - FakeInstance.formatName_ = formatName_; + (FakeInstance as any).formatName_ = formatName_; PATH = 'projects/' + spanner.projectId + '/instances/' + NAME; spanner.request = util.noop; @@ -334,7 +334,7 @@ describe('Spanner', () => { }); it('should set the correct defaults on the request', done => { - FakeInstance.formatName_ = function(projectId, name) { + (FakeInstance as any).formatName_ = function(projectId, name) { assert.strictEqual(projectId, spanner.projectId); assert.strictEqual(name, NAME); return PATH; @@ -366,7 +366,7 @@ describe('Spanner', () => { }); it('should accept a path', done => { - FakeInstance.formatName_ = function(projectId, name) { + (FakeInstance as any).formatName_ = function(projectId, name) { assert.strictEqual(name, PATH); setImmediate(done); return name; @@ -445,7 +445,7 @@ describe('Spanner', () => { it('should create an Instance and return an Operation', done => { const formattedName = 'formatted-name'; - FakeInstance.formatName_ = function() { + (FakeInstance as any).formatName_ = function() { return formattedName; }; @@ -558,8 +558,7 @@ describe('Spanner', () => { const instance = arguments[1].pop(); assert.strictEqual(instance, fakeInstanceInstance); - assert.strictEqual(instance.metadata, GAX_RESPONSE_ARGS[1][0]); - + assert.strictEqual(instance.metadata, GAX_RESPONSE_ARGS[1]![0]); assert.strictEqual(arguments[2], GAX_RESPONSE_ARGS[2]); done(); diff --git a/test/instance.js b/test/instance.ts similarity index 98% rename from test/instance.js rename to test/instance.ts index b251baf3c..84563b7e8 100644 --- a/test/instance.js +++ b/test/instance.ts @@ -16,7 +16,8 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; +import { ApiError } from '@google-cloud/common'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {util} = require('@google-cloud/common-grpc'); @@ -487,7 +488,7 @@ describe('Instance', () => { }); describe('autoCreate', () => { - const error = new Error('Error.'); + const error = new ApiError('Error.'); error.code = 5; const OPTIONS = { @@ -568,7 +569,7 @@ describe('Instance', () => { it('should not auto create without error code 5', done => { const error = new Error('Error.'); - error.code = 'NOT-5'; + (error as any).code = 'NOT-5'; const options = { autoCreate: true, @@ -589,7 +590,7 @@ describe('Instance', () => { }); it('should not auto create unless requested', done => { - const error = new Error('Error.'); + const error = new ApiError('Error.'); error.code = 5; instance.getMetadata = function(callback) { @@ -703,7 +704,7 @@ describe('Instance', () => { }, ]; - const REQUEST_RESPONSE_ARGS = [null, DATABASES, {}]; + const REQUEST_RESPONSE_ARGS: any = [null, DATABASES, {}]; beforeEach(() => { instance.request = function(config, callback) { diff --git a/test/partial-result-stream.js b/test/partial-result-stream.ts similarity index 99% rename from test/partial-result-stream.js rename to test/partial-result-stream.ts index d89fc6ac4..9287a42c8 100644 --- a/test/partial-result-stream.js +++ b/test/partial-result-stream.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const checkpointStream = require('checkpoint-stream'); const concat = require('concat-stream'); const extend = require('extend'); @@ -33,7 +33,7 @@ fakeCheckpointStream.obj = function() { ); }; -let FakeRowBuilderOverrides = {}; +let FakeRowBuilderOverrides: any = {}; function FakeRowBuilder() { this.calledWith_ = arguments; } diff --git a/test/row-builder.js b/test/row-builder.ts similarity index 97% rename from test/row-builder.js rename to test/row-builder.ts index 4621b71c0..a80f54f81 100644 --- a/test/row-builder.js +++ b/test/row-builder.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {util} = require('@google-cloud/common-grpc'); @@ -58,7 +58,7 @@ describe('RowBuilder', () => { }); beforeEach(() => { - FakeGrpcService.decodeValue_ = util.noop; + (FakeGrpcService as any).decodeValue_ = util.noop; decodeOverride = null; generateToJSONFromRowOverride = null; extend(RowBuilder, RowBuilderCached); @@ -120,7 +120,7 @@ describe('RowBuilder', () => { const expectedValue = {}; - FakeGrpcService.decodeValue_ = function() { + (FakeGrpcService as any).decodeValue_ = function() { return expectedValue; }; @@ -137,7 +137,7 @@ describe('RowBuilder', () => { const expectedValue = {}; - FakeGrpcService.decodeValue_ = function() { + (FakeGrpcService as any).decodeValue_ = function() { return { values: expectedValue, }; @@ -155,7 +155,7 @@ describe('RowBuilder', () => { }, }); - FakeGrpcService.decodeValue_ = function() { + (FakeGrpcService as any).decodeValue_ = function() { return value; }; @@ -480,7 +480,7 @@ describe('RowBuilder', () => { }); describe('flush', () => { - const ROWS = [[]]; + const ROWS: {}[][] = [[]]; for (let i = 0; i < FIELDS.length; i++) { ROWS[0].push({}); diff --git a/test/session-pool.js b/test/session-pool.ts similarity index 99% rename from test/session-pool.js rename to test/session-pool.ts index 00daa5108..0e9f1e1f3 100644 --- a/test/session-pool.js +++ b/test/session-pool.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const events = require('events'); const extend = require('extend'); const PQueue = require('p-queue'); @@ -24,14 +24,15 @@ const proxyquire = require('proxyquire'); const stackTrace = require('stack-trace'); const timeSpan = require('time-span'); -let pQueueOverride = null; +let pQueueOverride: any = null; function FakePQueue(options) { return new (pQueueOverride || PQueue)(options); } class FakeTransaction { - constructor(options) { + options; + constructor(options?) { this.options = options; } begin() { @@ -40,6 +41,14 @@ class FakeTransaction { } class FakeSession { + created; + deleted; + keptAlive; + createOptions; + txn?; + lastUsed?; + type?; + id?; constructor() { this.created = false; this.deleted = false; @@ -71,7 +80,7 @@ describe('SessionPool', () => { let sessionPool; let SessionPool; - const DATABASE = {}; + const DATABASE: any = {}; before(() => { SessionPool = proxyquire('../src/session-pool.js', { @@ -1284,7 +1293,7 @@ describe('SessionPool', () => { }); it('should return true if the session has gone bad', () => { - const fakeSession = {lastUsed: Date.now - 61 * 60000}; + const fakeSession = {lastUsed: Date.now() - 61 * 60000}; const isValid = sessionPool._isValidSession(fakeSession); assert.strictEqual(isValid, false); @@ -1467,7 +1476,7 @@ describe('SessionPool', () => { }, }; - global.setInterval = function(fn, interval) { + (global as any).setInterval = function(fn, interval) { if (intervalCalls++ !== callIndex) { return {unref: noop}; } @@ -1499,7 +1508,7 @@ describe('SessionPool', () => { }, }; - global.setInterval = function(fn, interval) { + (global as any).setInterval = function(fn, interval) { if (intervalCalls++ !== callIndex) { return {unref: noop}; } diff --git a/test/session.js b/test/session.ts similarity index 99% rename from test/session.js rename to test/session.ts index a13f2da76..5fc7db25c 100644 --- a/test/session.js +++ b/test/session.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {util} = require('@google-cloud/common-grpc'); @@ -50,7 +50,7 @@ describe('Session', () => { let Session; let session; - const DATABASE = { + const DATABASE: any = { request: util.noop, formattedName_: 'formatted-database-name', }; diff --git a/test/table.js b/test/table.ts similarity index 97% rename from test/table.js rename to test/table.ts index 95dc4ad73..eab2a702e 100644 --- a/test/table.js +++ b/test/table.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {split} = require('split-array-stream'); @@ -152,16 +152,16 @@ describe('Table', () => { const FORMATTED_OPTIONS = {}; const formatTimestampOptions = - FakeTransactionRequest.formatTimestampOptions; + (FakeTransactionRequest as any).formatTimestampOptions; - FakeTransactionRequest.formatTimestampOptions_ = function(options) { + (FakeTransactionRequest as any).formatTimestampOptions_ = function(options) { assert.strictEqual(options, OPTIONS); return FORMATTED_OPTIONS; }; FakeTransactionRequest.prototype = { createReadStream: function(name, query) { - FakeTransactionRequest.formatTimestampOptions_ = formatTimestampOptions; + (FakeTransactionRequest as any).formatTimestampOptions_ = formatTimestampOptions; assert.strictEqual( query.transaction.singleUse.readOnly, diff --git a/test/transaction-request.js b/test/transaction-request.ts similarity index 99% rename from test/transaction-request.js rename to test/transaction-request.ts index 3299b2ef6..708915972 100644 --- a/test/transaction-request.js +++ b/test/transaction-request.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const extend = require('extend'); const proxyquire = require('proxyquire'); const {split} = require('split-array-stream'); @@ -44,7 +44,7 @@ const fakePfy = extend({}, pfy, { }, }); -const fakeCodec = { +const fakeCodec: any = { encode: util.noop, }; @@ -64,7 +64,7 @@ describe('TransactionRequest', () => { }); beforeEach(() => { - FakeGrpcService.encodeValue_ = util.noop; + (FakeGrpcService as any).encodeValue_ = util.noop; fakeCodec.encode = util.noop; transactionRequest = new TransactionRequest(); transactionRequest.request = util.noop; diff --git a/test/transaction.js b/test/transaction.ts similarity index 98% rename from test/transaction.js rename to test/transaction.ts index 63f30883c..a918a79e3 100644 --- a/test/transaction.js +++ b/test/transaction.ts @@ -16,7 +16,7 @@ 'use strict'; -const assert = require('assert'); +import * as assert from 'assert'; const common = require('@google-cloud/common-grpc'); const extend = require('extend'); const gax = require('google-gax'); @@ -58,7 +58,7 @@ const fakePfy = extend({}, pfy, { }, }); -function FakeGrpcService() {} +const FakeGrpcService = class {}; function FakePartialResultStream() { this.calledWith_ = arguments; @@ -69,7 +69,7 @@ function FakeTransactionRequest(options) { this.options = options; } -const fakeCodec = { +const fakeCodec: any = { encode: util.noop, }; @@ -115,7 +115,7 @@ describe('Transaction', () => { }); beforeEach(() => { - FakeGrpcService.objToStruct_ = util.noop; + (FakeGrpcService as any).objToStruct_ = util.noop; FakeRetryInfo.decode = util.noop; extend(Transaction, TransactionCached); @@ -156,7 +156,7 @@ describe('Transaction', () => { }); it('should inherit from TransactionRequest', () => { - const OPTIONS = {}; + const OPTIONS: any= {}; transaction = new Transaction(SESSION, OPTIONS); @@ -223,7 +223,7 @@ describe('Transaction', () => { const fakeError = new Error('err'); const fakeRetryInfo = Buffer.from('hi'); - fakeError.metadata = { + (fakeError as any).metadata = { get: function(key) { assert.strictEqual(key, 'google.rpc.retryinfo-bin'); return [fakeRetryInfo]; @@ -257,7 +257,7 @@ describe('Transaction', () => { it('should create backoff from counter when delay is absent', () => { const fakeError = new Error('err'); - fakeError.metadata = { + (fakeError as any).metadata = { get: function() { return []; }, @@ -418,7 +418,7 @@ describe('Transaction', () => { ); }; - FakeTransactionRequest.fromProtoTimestamp_ = function(value) { + (FakeTransactionRequest as any).fromProtoTimestamp_ = function(value) { assert.strictEqual(value, fakeProtoTimestamp); return fakeDate; }; @@ -1277,7 +1277,7 @@ describe('Transaction', () => { }); beforeEach(() => { - global.setTimeout = function() {}; + (global as any).setTimeout = function() {}; transaction.runFn_ = function() {}; transaction.begin = function(callback) { @@ -1297,7 +1297,7 @@ describe('Transaction', () => { }); it('should execute run function after timeout', done => { - global.setTimeout = function(cb, timeout) { + (global as any).setTimeout = function(cb, timeout) { assert.strictEqual(timeout, fakeDelay); cb(); }; diff --git a/tsconfig.json b/tsconfig.json index 21951fc9e..2813d0e6a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,8 @@ "allowJs": true, "declaration": false, "skipLibCheck": true, - "noImplicitAny": false + "noImplicitAny": false, + "noImplicitThis": false }, "include": [ "src/*.ts",