From 6cb45c55e358fc4e4e6551759deca6a9bef546e8 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 8 Dec 2016 17:23:10 -0800 Subject: [PATCH] Use No Implicit Any In TS Extension (#16878) Use noImplicitAny in the TS Extension (the TS team suggests enabling this option for most code). --- .../typescript/src/features/formattingProvider.ts | 2 ++ extensions/typescript/src/typescriptService.ts | 2 +- extensions/typescript/src/utils/electronForkStart.ts | 12 ++++++------ extensions/typescript/tsconfig.json | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/extensions/typescript/src/features/formattingProvider.ts b/extensions/typescript/src/features/formattingProvider.ts index c5f730c87ad..4e4171d42a9 100644 --- a/extensions/typescript/src/features/formattingProvider.ts +++ b/extensions/typescript/src/features/formattingProvider.ts @@ -23,6 +23,8 @@ interface Configuration { insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean; placeOpenBraceOnNewLineForFunctions: boolean; placeOpenBraceOnNewLineForControlBlocks: boolean; + + [key: string]: boolean; } namespace Configuration { diff --git a/extensions/typescript/src/typescriptService.ts b/extensions/typescript/src/typescriptService.ts index a815a86a601..ac2e3150902 100644 --- a/extensions/typescript/src/typescriptService.ts +++ b/extensions/typescript/src/typescriptService.ts @@ -69,7 +69,7 @@ export interface ITypescriptServiceClient { onProjectLanguageServiceStateChanged: Event; - logTelemetry(eventName: string, properties?: { [prop: string]: string }); + logTelemetry(eventName: string, properties?: { [prop: string]: string }): void; experimentalAutoBuild: boolean; apiVersion: API; diff --git a/extensions/typescript/src/utils/electronForkStart.ts b/extensions/typescript/src/utils/electronForkStart.ts index f374ada0086..2a7d4d5e132 100644 --- a/extensions/typescript/src/utils/electronForkStart.ts +++ b/extensions/typescript/src/utils/electronForkStart.ts @@ -14,7 +14,7 @@ var log = (function () { } var isFirst = true; var LOG_LOCATION = 'C:\\stdFork.log'; - return function log(str) { + return function log(str: any) { if (isFirst) { isFirst = false; fs.writeFileSync(LOG_LOCATION, str + '\n'); @@ -55,13 +55,13 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']); // handle process.stderr (process).__defineGetter__('stderr', function () { return stdErrStream; }); - var fsWriteSyncString = function (fd, str, position, encoding) { + var fsWriteSyncString = function (fd: number, str: string, position: number, encoding?: string) { // fs.writeSync(fd, string[, position[, encoding]]); var buf = new Buffer(str, encoding || 'utf8'); return fsWriteSyncBuffer(fd, buf, 0, buf.length); }; - var fsWriteSyncBuffer = function (fd, buffer, off, len) { + var fsWriteSyncBuffer = function (fd: number, buffer: Buffer, off: number, len: number) { off = Math.abs(off | 0); len = Math.abs(len | 0); @@ -97,8 +97,8 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']); // handle fs.writeSync(1, ...) var originalWriteSync = fs.writeSync; - fs.writeSync = function (fd, data, position, encoding) { - if (fd !== 1 || fd !== 2) { + fs.writeSync = function (fd: number, data: any, position: number, encoding?: string) { + if (fd !== 1 && fd !== 2) { return originalWriteSync.apply(fs, arguments); } // usage: @@ -125,7 +125,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']); (function () { // Begin listening to stdin pipe - var server = net.createServer(function (stream) { + var server = net.createServer(function (stream: any) { // Stop accepting new connections, keep the existing one alive server.close(); diff --git a/extensions/typescript/tsconfig.json b/extensions/typescript/tsconfig.json index 17918ca332a..d7f4774cfa6 100644 --- a/extensions/typescript/tsconfig.json +++ b/extensions/typescript/tsconfig.json @@ -7,7 +7,8 @@ "es2015.promise" ], "outDir": "./out", - "strictNullChecks": true + "strictNullChecks": true, + "noImplicitAny": true }, "exclude": [ "node_modules",